我有一个问题。我想迭代mapreduce程序中的reduce结果(Reduce键类型为Text)。我怎样才能做到这一点?我可以将结果转换为ResultSet吗? 这是我的代码:
protected void setup(Mapper.Context context) throws IOException, InterruptedException {
sourceColumn = ByteBufferUtil.bytes(context.getConfiguration().get(CONF_COLUMN_NAME));
}
public void map(ByteBuffer key, SortedMap<ByteBuffer, IColumn> columns, Context context) throws IOException, InterruptedException
{
for (IColumn col: columns.values()){
String value = ByteBufferUtil.string((col.value()));
StringTokenizer itr = new StringTokenizer(value);
while (itr.hasMoreTokens()) {
word.set(new Text(itr.nextToken()));
context.write(word, one);
}
}
}
protected void setup(Reducer.Context context) throws IOException, InterruptedException
{
// The row key is the name of the column from which we read the text
outputKey = ByteBufferUtil.bytes(context.getConfiguration().get(CONF_COLUMN_NAME));
}
public void reduce(Text word, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException
{
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
}
context.write(outputKey, Collections.singletonList(getMutation(word, sum)));
Text date = context.getCurrentKey();
}
现在我想迭代一下。例如像结果集或数组..