use of org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier in project hbase by apache.
the class RequestConverter method buildMutateRequest.
/**
* Create a protocol buffer MutateRequest for a put
*
* @param regionName
* @param put
* @return a mutate request
* @throws IOException
*/
public static MutateRequest buildMutateRequest(final byte[] regionName, final Put put) throws IOException {
MutateRequest.Builder builder = MutateRequest.newBuilder();
RegionSpecifier region = buildRegionSpecifier(RegionSpecifierType.REGION_NAME, regionName);
builder.setRegion(region);
builder.setMutation(ProtobufUtil.toMutation(MutationType.PUT, put, MutationProto.newBuilder()));
return builder.build();
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier in project hbase by apache.
the class RequestConverter method buildScanRequest.
/**
* Create a protocol buffer ScanRequest for a client Scan
*
* @param regionName
* @param scan
* @param numberOfRows
* @param closeScanner
* @return a scan request
* @throws IOException
*/
public static ScanRequest buildScanRequest(byte[] regionName, Scan scan, int numberOfRows, boolean closeScanner) throws IOException {
ScanRequest.Builder builder = ScanRequest.newBuilder();
RegionSpecifier region = buildRegionSpecifier(RegionSpecifierType.REGION_NAME, regionName);
builder.setNumberOfRows(numberOfRows);
builder.setCloseScanner(closeScanner);
builder.setRegion(region);
builder.setScan(ProtobufUtil.toScan(scan));
builder.setClientHandlesPartials(true);
builder.setClientHandlesHeartbeats(true);
builder.setTrackScanMetrics(scan.isScanMetricsEnabled());
if (scan.getLimit() > 0) {
builder.setLimitOfRows(scan.getLimit());
}
return builder.build();
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier in project hbase by apache.
the class RequestConverter method buildIncrementRequest.
/**
* Create a protocol buffer MutateRequest for a client increment
*
* @param regionName
* @param row
* @param family
* @param qualifier
* @param amount
* @param durability
* @return a mutate request
*/
public static MutateRequest buildIncrementRequest(final byte[] regionName, final byte[] row, final byte[] family, final byte[] qualifier, final long amount, final Durability durability, long nonceGroup, long nonce) {
MutateRequest.Builder builder = MutateRequest.newBuilder();
RegionSpecifier region = buildRegionSpecifier(RegionSpecifierType.REGION_NAME, regionName);
builder.setRegion(region);
MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
mutateBuilder.setRow(UnsafeByteOperations.unsafeWrap(row));
mutateBuilder.setMutateType(MutationType.INCREMENT);
mutateBuilder.setDurability(ProtobufUtil.toDurability(durability));
ColumnValue.Builder columnBuilder = ColumnValue.newBuilder();
columnBuilder.setFamily(UnsafeByteOperations.unsafeWrap(family));
QualifierValue.Builder valueBuilder = QualifierValue.newBuilder();
valueBuilder.setValue(UnsafeByteOperations.unsafeWrap(Bytes.toBytes(amount)));
valueBuilder.setQualifier(UnsafeByteOperations.unsafeWrap(qualifier));
columnBuilder.addQualifierValue(valueBuilder.build());
mutateBuilder.addColumnValue(columnBuilder.build());
if (nonce != HConstants.NO_NONCE) {
mutateBuilder.setNonce(nonce);
}
builder.setMutation(mutateBuilder.build());
if (nonceGroup != HConstants.NO_NONCE) {
builder.setNonceGroup(nonceGroup);
}
return builder.build();
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier in project hbase by apache.
the class RequestConverter method buildMutateRequest.
/**
* Create a protocol buffer MutateRequest for a client increment
*
* @param regionName
* @param increment
* @return a mutate request
*/
public static MutateRequest buildMutateRequest(final byte[] regionName, final Increment increment, final long nonceGroup, final long nonce) {
MutateRequest.Builder builder = MutateRequest.newBuilder();
RegionSpecifier region = buildRegionSpecifier(RegionSpecifierType.REGION_NAME, regionName);
builder.setRegion(region);
if (nonce != HConstants.NO_NONCE && nonceGroup != HConstants.NO_NONCE) {
builder.setNonceGroup(nonceGroup);
}
builder.setMutation(ProtobufUtil.toMutation(increment, MutationProto.newBuilder(), nonce));
return builder.build();
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier in project hbase by apache.
the class RequestConverter method buildMutateRequest.
/**
* Create a protocol buffer MutateRequest for an append
*
* @param regionName
* @param append
* @return a mutate request
* @throws IOException
*/
public static MutateRequest buildMutateRequest(final byte[] regionName, final Append append, long nonceGroup, long nonce) throws IOException {
MutateRequest.Builder builder = MutateRequest.newBuilder();
RegionSpecifier region = buildRegionSpecifier(RegionSpecifierType.REGION_NAME, regionName);
builder.setRegion(region);
if (nonce != HConstants.NO_NONCE && nonceGroup != HConstants.NO_NONCE) {
builder.setNonceGroup(nonceGroup);
}
builder.setMutation(ProtobufUtil.toMutation(MutationType.APPEND, append, MutationProto.newBuilder(), nonce));
return builder.build();
}
Aggregations