Verify.java 文件源码

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

项目:gora-boot 作者:
public void reduce(LongWritable key, Iterable<VLongWritable> values, Context context) throws IOException, InterruptedException {

  int defCount = 0;

  refs.clear();
  for (VLongWritable type : values) {
    if (type.get() == -1) {
      defCount++;
    } else {
      refs.add(type.get());
    }
  }

  // TODO check for more than one def, should not happen

  if (defCount == 0 && refs.size() > 0) {
    // this is bad, found a node that is referenced but not defined. It must have been lost, emit some info about this node for debugging purposes.

    StringBuilder sb = new StringBuilder();
    String comma = "";
    for (Long ref : refs) {
      sb.append(comma);
      comma = ",";
      sb.append(String.format(Locale.getDefault(), "%016x", ref));
    }

    context.write(new Text(String.format(Locale.getDefault(), "%016x", key.get())), new Text(sb.toString()));
    context.getCounter(Counts.UNDEFINED).increment(1);

  } else if (defCount > 0 && refs.size() == 0) {
    // node is defined but not referenced
    context.getCounter(Counts.UNREFERENCED).increment(1);
  } else {
    // node is defined and referenced
    context.getCounter(Counts.REFERENCED).increment(1);
  }

}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号