我有以下Hadoop映射器类:
public static class Map extends Mapper<NullWritable, RepublicRecord, NullWritable, Text> {
private Text output = new Text();
private NullWritable nothing = NullWritable.get();
private static String[] outputFields = new String[0];
public void map(NullWritable key, RepublicRecord value, Context context) throws IOException, InterruptedException {
String line = StringUtils.join(value.GetData(outputFields), ",");
output.set(line);
context.write(nothing, output);
}
public static void SetOutputFields(String fieldString) {
outputFields = fieldString.split(",");
}
}
我致电Map.SetOutputFields("one,two")
,然后致电map(key, value, context)
。当我这样做时,一个0长度的字符串数组被传递给value
的{{1}}方法。
我希望这个字符串数组包含&#34; one&#34;和&#34;两个&#34;会被传递给GetData()
而不是......
这里发生了什么?有办法解决吗?