0

我有个问题。我想在mapreduce程序中遍历reduce结果(Text类型的Reduce键)。我怎样才能做到这一点?我可以将结果转换为 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();
    }

现在我想迭代日期。例如像结果集或数组..

4

0 回答 0