当前位置: 首页>>代码示例>>Java>>正文


Java ImmutableBytesWritable.equals方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.io.ImmutableBytesWritable.equals方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableBytesWritable.equals方法的具体用法?Java ImmutableBytesWritable.equals怎么用?Java ImmutableBytesWritable.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.io.ImmutableBytesWritable的用法示例。


在下文中一共展示了ImmutableBytesWritable.equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: finishBatchAndCompareHashes

import org.apache.hadoop.hbase.io.ImmutableBytesWritable; //导入方法依赖的package包/类
/**
 * Finish the currently open hash batch.
 * Compare the target hash to the given source hash.
 * If they do not match, then sync the covered key range.
 */
private void finishBatchAndCompareHashes(Context context)
    throws IOException, InterruptedException {
  targetHasher.finishBatch();
  context.getCounter(Counter.BATCHES).increment(1);
  if (targetHasher.getBatchSize() == 0) {
    context.getCounter(Counter.EMPTY_BATCHES).increment(1);
  }
  ImmutableBytesWritable targetHash = targetHasher.getBatchHash();
  if (targetHash.equals(currentSourceHash)) {
    context.getCounter(Counter.HASHES_MATCHED).increment(1);
  } else {
    context.getCounter(Counter.HASHES_NOT_MATCHED).increment(1);
    
    ImmutableBytesWritable stopRow = nextSourceKey == null
                                      ? new ImmutableBytesWritable(sourceTableHash.stopRow)
                                      : nextSourceKey;
    
    if (LOG.isDebugEnabled()) {
      LOG.debug("Hash mismatch.  Key range: " + toHex(targetHasher.getBatchStartKey())
          + " to " + toHex(stopRow)
          + " sourceHash: " + toHex(currentSourceHash)
          + " targetHash: " + toHex(targetHash));
    }
    
    syncRange(context, targetHasher.getBatchStartKey(), stopRow);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:33,代码来源:SyncTable.java

示例2: writePartitions

import org.apache.hadoop.hbase.io.ImmutableBytesWritable; //导入方法依赖的package包/类
/**
 * Write out a {@link SequenceFile} that can be read by
 * {@link TotalOrderPartitioner} that contains the split points in startKeys.
 */
@SuppressWarnings("deprecation")
private static void writePartitions(Configuration conf, Path partitionsPath,
    List<ImmutableBytesWritable> startKeys) throws IOException {
  LOG.info("Writing partition information to " + partitionsPath);
  if (startKeys.isEmpty()) {
    throw new IllegalArgumentException("No regions passed");
  }

  // We're generating a list of split points, and we don't ever
  // have keys < the first region (which has an empty start key)
  // so we need to remove it. Otherwise we would end up with an
  // empty reducer with index 0
  TreeSet<ImmutableBytesWritable> sorted =
    new TreeSet<ImmutableBytesWritable>(startKeys);

  ImmutableBytesWritable first = sorted.first();
  if (!first.equals(HConstants.EMPTY_BYTE_ARRAY)) {
    throw new IllegalArgumentException(
        "First region of table should have empty start key. Instead has: "
        + Bytes.toStringBinary(first.get()));
  }
  sorted.remove(first);

  // Write the actual file
  FileSystem fs = partitionsPath.getFileSystem(conf);
  SequenceFile.Writer writer = SequenceFile.createWriter(
    fs, conf, partitionsPath, ImmutableBytesWritable.class,
    NullWritable.class);

  try {
    for (ImmutableBytesWritable startKey : sorted) {
      writer.append(startKey, NullWritable.get());
    }
  } finally {
    writer.close();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:42,代码来源:HFileOutputFormat2.java


注:本文中的org.apache.hadoop.hbase.io.ImmutableBytesWritable.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。