我正在研究Map-Reduce的问题。但我坚持在一个点上,我如何能够通过List<Text>为Mapper output?有没有可能?如果是的话,那么我们怎么能告诉configuration有关Mapper output class?
您可以将ArrayWritable类用作映射器类中的值对象。请为您的mapper类参考以下代码段,
ArrayWritable arrayWritable = new ArrayWritable(Text.class);
Text [] textValues = new Text[2];
textValues[0] = new Text("value1");
textValues[1] = new Text("value1");
arrayWritable.set(textValues );
context.write(key , arrayWritable );
Run Code Online (Sandbox Code Playgroud)
在驱动程序类中将值类设置如下,
job.setMapOutputValueClass(ArrayWritable.class);
Run Code Online (Sandbox Code Playgroud)