你好,游客 登录
背景:
阅读新闻

MultipleInputs.addInputPath注意点

[日期:2013-04-08] 来源:  作者: [字体: ]
原创,转载请注明出处:

使用MultipleInputs.addInputPath添加多输入源(超过两个)的时候:
MultipleInputs.addInputPath(conf, new Path(otheArgs[0]), TextInputFormat.class,JoinNodeMapper2.class);
MultipleInputs.addInputPath(conf, new Path(otheArgs[1]), TextInputFormat.class,JoinMemMapper2.class);
MultipleInputs.addInputPath(conf, new Path(otheArgs[2]), TextInputFormat.class,JoinCPUMapper2.class);

我的文件格式是:
otheArgs[0]指向的文件格式:
key1 keyname1
key2 keyname2

otheArgs[1]指向的文件格式:
key1 valA1
key2 valA2

otheArgs[2]指向的文件格式:
key1 valB1
key2 valB2


在elipse里面运行指定参数的时候,如果otheArgs[2]和otheArgs[1]相同,那么此时MultipleInputs只执行其中一条addInputPath语句,我的测试环境中测试出来的结果就是执行了
MultipleInputs.addInputPath(conf, new Path(otheArgs[2]), TextInputFormat.class,JoinCPUMapper2.class);

1.要求otheArgs[2]和otheArgs[1]要不一样。
2.reduce之后生成文件是:
key1 keyname1 valA1
key2 keyname2 valA2
key1 keyname1 valB1
key2 keyname2 valB2

而不是:
key1 keyname1 valA1 valB1
key2 keyname2 valA2 valB2

所以要实现第二种join的结果,我觉得还是要使用MapReduce job流的相关控制了。






收藏 推荐 打印 | 录入:admin | 阅读:
相关新闻