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


Java HLogKey.getScopes方法代码示例

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


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

示例1: buildReplicateWALEntryRequest

import org.apache.hadoop.hbase.regionserver.wal.HLogKey; //导入方法依赖的package包/类
/**
 * Create a new ReplicateWALEntryRequest from a list of HLog entries
 *
 * @param entries the HLog entries to be replicated
 * @return a pair of ReplicateWALEntryRequest and a CellScanner over all the WALEdit values
 * found.
 */
public static Pair<AdminProtos.ReplicateWALEntryRequest, CellScanner>
    buildReplicateWALEntryRequest(final HLog.Entry[] entries) {
  // Accumulate all the KVs seen in here.
  List<List<? extends Cell>> allkvs = new ArrayList<List<? extends Cell>>(entries.length);
  int size = 0;
  WALProtos.FamilyScope.Builder scopeBuilder = WALProtos.FamilyScope.newBuilder();
  AdminProtos.WALEntry.Builder entryBuilder = AdminProtos.WALEntry.newBuilder();
  AdminProtos.ReplicateWALEntryRequest.Builder builder =
    AdminProtos.ReplicateWALEntryRequest.newBuilder();
  HBaseProtos.UUID.Builder uuidBuilder = HBaseProtos.UUID.newBuilder();
  for (HLog.Entry entry: entries) {
    entryBuilder.clear();
    // TODO: this duplicates a lot in HLogKey#getBuilder
    WALProtos.WALKey.Builder keyBuilder = entryBuilder.getKeyBuilder();
    HLogKey key = entry.getKey();
    keyBuilder.setEncodedRegionName(
      HBaseZeroCopyByteString.wrap(key.getEncodedRegionName()));
    keyBuilder.setTableName(HBaseZeroCopyByteString.wrap(key.getTablename().getName()));
    keyBuilder.setLogSequenceNumber(key.getLogSeqNum());
    keyBuilder.setWriteTime(key.getWriteTime());
    if (key.getNonce() != HConstants.NO_NONCE) {
      keyBuilder.setNonce(key.getNonce());
    }
    if (key.getNonceGroup() != HConstants.NO_NONCE) {
      keyBuilder.setNonceGroup(key.getNonceGroup());
    }
    for(UUID clusterId : key.getClusterIds()) {
      uuidBuilder.setLeastSigBits(clusterId.getLeastSignificantBits());
      uuidBuilder.setMostSigBits(clusterId.getMostSignificantBits());
      keyBuilder.addClusterIds(uuidBuilder.build());
    }
    WALEdit edit = entry.getEdit();
    NavigableMap<byte[], Integer> scopes = key.getScopes();
    if (scopes != null && !scopes.isEmpty()) {
      for (Map.Entry<byte[], Integer> scope: scopes.entrySet()) {
        scopeBuilder.setFamily(HBaseZeroCopyByteString.wrap(scope.getKey()));
        WALProtos.ScopeType scopeType =
            WALProtos.ScopeType.valueOf(scope.getValue().intValue());
        scopeBuilder.setScopeType(scopeType);
        keyBuilder.addScopes(scopeBuilder.build());
      }
    }
    List<KeyValue> kvs = edit.getKeyValues();
    // Add up the size.  It is used later serializing out the kvs.
    for (KeyValue kv: kvs) {
      size += kv.getLength();
    }
    // Collect up the kvs
    allkvs.add(kvs);
    // Write out how many kvs associated with this entry.
    entryBuilder.setAssociatedCellCount(kvs.size());
    builder.addEntry(entryBuilder.build());
  }
  return new Pair<AdminProtos.ReplicateWALEntryRequest, CellScanner>(builder.build(),
    getCellScanner(allkvs, size));
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:64,代码来源:ReplicationProtbufUtil.java

示例2: buildReplicateWALEntryRequest

import org.apache.hadoop.hbase.regionserver.wal.HLogKey; //导入方法依赖的package包/类
/**
 * Create a new ReplicateWALEntryRequest from a list of HLog entries
 *
 * @param entries the HLog entries to be replicated
 * @return a pair of ReplicateWALEntryRequest and a CellScanner over all the WALEdit values
 * found.
 */
public static Pair<AdminProtos.ReplicateWALEntryRequest, CellScanner>
    buildReplicateWALEntryRequest(final HLog.Entry[] entries) {
  // Accumulate all the KVs seen in here.
  List<List<? extends Cell>> allkvs = new ArrayList<List<? extends Cell>>(entries.length);
  int size = 0;
  WALProtos.FamilyScope.Builder scopeBuilder = WALProtos.FamilyScope.newBuilder();
  AdminProtos.WALEntry.Builder entryBuilder = AdminProtos.WALEntry.newBuilder();
  AdminProtos.ReplicateWALEntryRequest.Builder builder =
    AdminProtos.ReplicateWALEntryRequest.newBuilder();
  HBaseProtos.UUID.Builder uuidBuilder = HBaseProtos.UUID.newBuilder();
  for (HLog.Entry entry: entries) {
    entryBuilder.clear();
    WALProtos.WALKey.Builder keyBuilder = entryBuilder.getKeyBuilder();
    HLogKey key = entry.getKey();
    keyBuilder.setEncodedRegionName(
      ZeroCopyLiteralByteString.wrap(key.getEncodedRegionName()));
    keyBuilder.setTableName(ZeroCopyLiteralByteString.wrap(key.getTablename().getName()));
    keyBuilder.setLogSequenceNumber(key.getLogSeqNum());
    keyBuilder.setWriteTime(key.getWriteTime());
    for(UUID clusterId : key.getClusterIds()) {
      uuidBuilder.setLeastSigBits(clusterId.getLeastSignificantBits());
      uuidBuilder.setMostSigBits(clusterId.getMostSignificantBits());
      keyBuilder.addClusterIds(uuidBuilder.build());
    }
    WALEdit edit = entry.getEdit();
    NavigableMap<byte[], Integer> scopes = key.getScopes();
    if (scopes != null && !scopes.isEmpty()) {
      for (Map.Entry<byte[], Integer> scope: scopes.entrySet()) {
        scopeBuilder.setFamily(ZeroCopyLiteralByteString.wrap(scope.getKey()));
        WALProtos.ScopeType scopeType =
            WALProtos.ScopeType.valueOf(scope.getValue().intValue());
        scopeBuilder.setScopeType(scopeType);
        keyBuilder.addScopes(scopeBuilder.build());
      }
    }
    List<KeyValue> kvs = edit.getKeyValues();
    // Add up the size.  It is used later serializing out the kvs.
    for (KeyValue kv: kvs) {
      size += kv.getLength();
    }
    // Collect up the kvs
    allkvs.add(kvs);
    // Write out how many kvs associated with this entry.
    entryBuilder.setAssociatedCellCount(kvs.size());
    builder.addEntry(entryBuilder.build());
  }
  return new Pair<AdminProtos.ReplicateWALEntryRequest, CellScanner>(builder.build(),
    getCellScanner(allkvs, size));
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:57,代码来源:ReplicationProtbufUtil.java


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