Hadoop Streaming Python 多输入文件单映射器

Com*_*low 0 python hadoop mapreduce cloudera hadoop-streaming

我有一个映射器。

for line in sys.stdin:
    #if line is from file1
    #process it based on some_arbitrary_logic
    #emit k,v

    #if line is from file2
    #process it based on another_arbitrary_logic
    #emit k, v
Run Code Online (Sandbox Code Playgroud)

我需要通过 hadoop 流 API-input file1和另一个-input file2.

我如何实现这一目标?我怎么知道STDINhadoop流给我的哪一行属于哪个文件?

更新

File1

Fruit, Vendor, Cost

Oranges, FreshOrangesCompany, 50
Apples, FreshAppleCompany, 100

File2

Vendor, Location, NumberOfOffices

FreshAppleCompany, NewZealand, 45
FreshOrangeCompany, FijiIslands, 100
Run Code Online (Sandbox Code Playgroud)

我需要做的是打印出他们卖橙子的办公室数量。

Oranges 100.

所以这两个文件都需要到INPUT映射器。

Pra*_*ati 5

os.environ["map.input.file"] 在映射器 python 代码中应该给出映射器正在处理的块的文件名。