我的映射器实现
public class SimpleMapper extends Mapper<Text, Text, Text, MapWritable> {
@Override
protected void map(Text key, Text value,Context context)
throws IOException, InterruptedException {
MapWritable writable = new LinkedMapWritable();
writable.put("unique_key","one");
writable.put("another_key","two");
context.write(new Text("key"),writable );
}
}
Reducer 的实现是:
public class SimpleReducer extends Reducer<Text, MapWritable, NullWritable, Text> {
@Override
protected void reduce(Text key, Iterable<MapWritable> values,Context context)
throws IOException, InterruptedException {
// The map writables have to be ordered based on the "unique_key" inserted into it
}
}
我必须使用二级排序吗?还有其他方法吗?