【发布时间】:2013-04-03 19:50:52
【问题描述】:
关注Pig: Force UDF to occur in Reducer or set number of mappers。我有一个 UDF,它在我的猪工作流程中作为地图步骤运行。它需要一个 X 文件列表,每个从前一步保存它的减速器 1 个。我希望有 X 映射器(每个输入文件 1 个)来运行这个 UDF,因为它非常耗时,所以 Pig 没有像我想要的那样并行运行它。基于Hadoop streaming: single file or multi file per map. Don't Split,我认为解决方案是防止分裂,所以我做了一个猪加载函数。
public class ForceMapperPerInputFile extends PigStorage {
@Override
public InputFormat getInputFormat() {
return new MapperPerFileInputFormat();
}
}
class MapperPerFileInputFormat extends PigTextInputFormat {
@Override
protected boolean isSplitable(JobContext context, Path file) {
return false;
}
}
当我使用它时,它的效果与我想要的完全相反,映射器任务的数量减少了近一半。
我怎样才能真正为每个输入文件强制使用一个映射器?
【问题讨论】: