org.apache.hbase.thirdparty.com.google.protobuf.ByteString.toByteArray()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中org.apache.hbase.thirdparty.com.google.protobuf.ByteString.toByteArray()方法的一些代码示例,展示了ByteString.toByteArray()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteString.toByteArray()方法的具体详情如下:
包路径:org.apache.hbase.thirdparty.com.google.protobuf.ByteString
类名称:ByteString
方法名:toByteArray

ByteString.toByteArray介绍

暂无

代码示例

代码示例来源:origin: apache/hbase

@Override
 public byte[] uncompress(ByteString data, Enum dictIndex) {
  return data.toByteArray();
 }
}

代码示例来源:origin: apache/hbase

private String getHFilePath(TableName table, BulkLoadDescriptor bld, String storeFile,
  byte[] family) {
 return new StringBuilder(100).append(table.getNamespaceAsString()).append(Path.SEPARATOR)
   .append(table.getQualifierAsString()).append(Path.SEPARATOR)
   .append(Bytes.toString(bld.getEncodedRegionName().toByteArray())).append(Path.SEPARATOR)
   .append(Bytes.toString(family)).append(Path.SEPARATOR).append(storeFile).toString();
}

代码示例来源:origin: apache/hbase

/**
  * Fill our map with content of the pb we read off disk
  * @param fip protobuf message to read
  */
 void parsePB(final HFileProtos.FileInfoProto fip) {
  this.map.clear();
  for (BytesBytesPair pair: fip.getMapEntryList()) {
   this.map.put(pair.getFirst().toByteArray(), pair.getSecond().toByteArray());
  }
 }
}

代码示例来源:origin: apache/hbase

public static Cursor toCursor(ClientProtos.Cursor cursor) {
 return ClientUtil.createCursor(cursor.getRow().toByteArray());
}

代码示例来源:origin: apache/hbase

/**
 * Print out some subset of a MutationProto rather than all of it and its data
 * @param proto Protobuf to print out
 * @return Short String of mutation proto
 */
static String toShortString(final MutationProto proto) {
 return "row=" + Bytes.toString(proto.getRow().toByteArray()) +
   ", type=" + proto.getMutateType().toString();
}

代码示例来源:origin: apache/hbase

public static Reference convert(final FSProtos.Reference r) {
 Reference result = new Reference();
 result.splitkey = r.getSplitkey().toByteArray();
 result.region = r.getRange() == FSProtos.Reference.Range.TOP? Range.top: Range.bottom;
 return result;
}

代码示例来源:origin: apache/hbase

/**
 * Find the HRegion based on a region specifier
 *
 * @param regionSpecifier the region specifier
 * @return the corresponding region
 * @throws IOException if the specifier is not null,
 *    but failed to find the region
 */
@VisibleForTesting
public HRegion getRegion(
  final RegionSpecifier regionSpecifier) throws IOException {
 return regionServer.getRegion(regionSpecifier.getValue().toByteArray());
}

代码示例来源:origin: apache/hbase

/**
 * get the split keys in form "byte [][]" from a CreateTableRequest proto
 *
 * @param proto the CreateTableRequest
 * @return the split keys
 */
public static byte [][] getSplitKeysArray(final CreateTableRequest proto) {
 byte [][] splitKeys = new byte[proto.getSplitKeysCount()][];
 for (int i = 0; i < proto.getSplitKeysCount(); ++i) {
  splitKeys[i] = proto.getSplitKeys(i).toByteArray();
 }
 return splitKeys;
}

代码示例来源:origin: apache/hbase

public static Cell toCell(ExtendedCellBuilder cellBuilder, final CellProtos.Cell cell) {
 return cellBuilder.clear()
     .setRow(cell.getRow().toByteArray())
     .setFamily(cell.getFamily().toByteArray())
     .setQualifier(cell.getQualifier().toByteArray())
     .setTimestamp(cell.getTimestamp())
     .setType((byte) cell.getCellType().getNumber())
     .setValue(cell.getValue().toByteArray())
     .build();
}

代码示例来源:origin: apache/hbase

public static Message getRequest(Service service,
  Descriptors.MethodDescriptor methodDesc,
  org.apache.hbase.thirdparty.com.google.protobuf.ByteString shadedRequest)
throws IOException {
 Message.Builder builderForType =
   service.getRequestPrototype(methodDesc).newBuilderForType();
 org.apache.hadoop.hbase.protobuf.ProtobufUtil.mergeFrom(builderForType,
   // TODO: COPY FROM SHADED TO NON_SHADED. DO I HAVE TOO?
   shadedRequest.toByteArray());
 return builderForType.build();
}

代码示例来源:origin: apache/hbase

private static Key getUnwrapKey(Configuration conf, String subject,
  EncryptionProtos.WrappedKey wrappedKey, Cipher cipher) throws IOException, KeyException {
 ByteArrayOutputStream out = new ByteArrayOutputStream();
 byte[] iv = wrappedKey.hasIv() ? wrappedKey.getIv().toByteArray() : null;
 Encryption.decryptWithSubjectKey(out, wrappedKey.getData().newInput(),
  wrappedKey.getLength(), subject, conf, cipher, iv);
 byte[] keyBytes = out.toByteArray();
 if (wrappedKey.hasHash()) {
  if (!Bytes.equals(wrappedKey.getHash().toByteArray(), Encryption.hash128(keyBytes))) {
   throw new KeyException("Key was not successfully unwrapped");
  }
 }
 return new SecretKeySpec(keyBytes, wrappedKey.getAlgorithm());
}

代码示例来源:origin: apache/hbase

private void checkBatchSizeAndLogLargeSize(MultiRequest request) {
 int sum = 0;
 String firstRegionName = null;
 for (RegionAction regionAction : request.getRegionActionList()) {
  if (sum == 0) {
   firstRegionName = Bytes.toStringBinary(regionAction.getRegion().getValue().toByteArray());
  }
  sum += regionAction.getActionCount();
 }
 if (sum > rowSizeWarnThreshold) {
  ld.logBatchWarning(firstRegionName, sum, rowSizeWarnThreshold);
 }
}

代码示例来源:origin: apache/hbase

@Override
protected void deserializeStateData(ProcedureStateSerializer serializer)
  throws IOException {
 BytesValue bytesValue = serializer.deserialize(BytesValue.class);
 ByteString dataString = bytesValue.getValue();
 if (dataString.isEmpty()) {
  data = null;
 } else {
  data = dataString.toByteArray();
 }
}

代码示例来源:origin: apache/hbase

@Override
public GetResponse get(RpcController controller, GetRequest request)
throws ServiceException {
 byte[] regionName = request.getRegion().getValue().toByteArray();
 Map<byte [], Result> m = this.gets.get(regionName);
 GetResponse.Builder builder = GetResponse.newBuilder();
 if (m != null) {
  byte[] row = request.getGet().getRow().toByteArray();
  builder.setResult(ProtobufUtil.toResult(m.get(row)));
 }
 return builder.build();
}

代码示例来源:origin: apache/hbase

@Override
@QosPriority(priority = HConstants.ADMIN_QOS)
public GetLastFlushedSequenceIdResponse getLastFlushedSequenceId(RpcController controller,
  GetLastFlushedSequenceIdRequest request) throws ServiceException {
 try {
  master.checkServiceStarted();
 } catch (IOException ioe) {
  throw new ServiceException(ioe);
 }
 byte[] encodedRegionName = request.getRegionName().toByteArray();
 RegionStoreSequenceIds ids = master.getServerManager()
  .getLastFlushedSequenceId(encodedRegionName);
 return ResponseConverter.buildGetLastFlushedSequenceIdResponse(ids);
}

代码示例来源:origin: apache/hbase

/**
 * Extract the region encoded name from the region manifest
 */
static String getRegionNameFromManifest(final SnapshotRegionManifest manifest) {
 byte[] regionName = RegionInfo.createRegionName(
     ProtobufUtil.toTableName(manifest.getRegionInfo().getTableName()),
     manifest.getRegionInfo().getStartKey().toByteArray(),
     manifest.getRegionInfo().getRegionId(), true);
 return RegionInfo.encodeRegionName(regionName);
}

代码示例来源:origin: apache/hbase

@Override
public CompletableFuture<byte[]> execProcedureWithReturn(String signature, String instance,
  Map<String, String> props) {
 ProcedureDescription proDesc =
   ProtobufUtil.buildProcedureDescription(signature, instance, props);
 return this.<byte[]> newMasterCaller()
   .action(
    (controller, stub) -> this.<ExecProcedureRequest, ExecProcedureResponse, byte[]> call(
     controller, stub, ExecProcedureRequest.newBuilder().setProcedure(proDesc).build(),
     (s, c, req, done) -> s.execProcedureWithRet(c, req, done),
     resp -> resp.hasReturnData() ? resp.getReturnData().toByteArray() : null))
   .call();
}

代码示例来源:origin: apache/hbase

public static CacheEvictionStats toCacheEvictionStats(
  HBaseProtos.CacheEvictionStats stats) throws IOException{
 CacheEvictionStatsBuilder builder = CacheEvictionStats.builder();
 builder.withEvictedBlocks(stats.getEvictedBlocks())
   .withMaxCacheSize(stats.getMaxCacheSize());
 if (stats.getExceptionCount() > 0) {
  for (HBaseProtos.RegionExceptionMessage exception : stats.getExceptionList()) {
   HBaseProtos.RegionSpecifier rs = exception.getRegion();
   byte[] regionName = rs.getValue().toByteArray();
   builder.addException(regionName, ProtobufUtil.toException(exception.getException()));
  }
 }
 return builder.build();
}

代码示例来源:origin: apache/hbase

@Override
public GetResponse get(RpcController controller, GetRequest request)
throws ServiceException {
 boolean metaRegion = isMetaRegion(request.getRegion().getValue().toByteArray(),
  request.getRegion().getType());
 if (!metaRegion) {
  return doGetResponse(request);
 }
 return doMetaGetResponse(meta, request);
}

代码示例来源:origin: apache/hbase

static GetResponse doMetaGetResponse(final SortedMap<byte [], Pair<HRegionInfo, ServerName>> meta,
  final GetRequest request) {
 ClientProtos.Result.Builder resultBuilder = ClientProtos.Result.newBuilder();
 ByteString row = request.getGet().getRow();
 Pair<HRegionInfo, ServerName> p = meta.get(row.toByteArray());
 if (p != null) {
  resultBuilder.addCell(getRegionInfo(row, p.getFirst()));
  resultBuilder.addCell(getServer(row, p.getSecond()));
 }
 resultBuilder.addCell(getStartCode(row));
 GetResponse.Builder builder = GetResponse.newBuilder();
 builder.setResult(resultBuilder.build());
 return builder.build();
}

相关文章