RowNumberJob.java 文件源码

java
阅读 20 收藏 0 点赞 0 评论 0

项目:Hadoop-Affinity 作者:
protected void reduce(ByteWritable key, Iterable<RowNumberWritable> values, Context context) throws IOException, InterruptedException {
    Iterator<RowNumberWritable> itr = values.iterator();
    if (!itr.hasNext()) {
        return;
    }

    long offset = 0;
    RowNumberWritable value = itr.next();
    while (itr.hasNext() && value.getCount() > 0) {
        offset += value.getCount();
        value = itr.next();
    }
    outputKey.set(Long.toString(offset++));
    context.write(outputKey, value.getValue());

    while(itr.hasNext()) {
        value = itr.next();
        outputKey.set(Long.toString(offset++));
        context.write(outputKey, value.getValue());
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号