@Override public byte[] uncompress(ByteString data, Enum dictIndex) { return data.toByteArray(); } }
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(); }
/** * 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()); } } }
public static Cursor toCursor(ClientProtos.Cursor cursor) { return ClientUtil.createCursor(cursor.getRow().toByteArray()); }
/** * 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(); }
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; }
/** * 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()); }
/** * 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; }
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(); }
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(); }
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()); }
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); } }
@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(); } }
@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(); }
@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); }
/** * 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); }
@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(); }
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(); }
@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); }
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(); }