public class BulkDeleteEndpoint extends org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteService implements CoprocessorService, Coprocessor
Scan scan = new Scan();
// set scan properties(rowkey range, filters, timerange etc).
HTable ht = ...;
long noOfDeletedRows = 0L;
Batch.Call<BulkDeleteService, BulkDeleteResponse> callable =
new Batch.Call<BulkDeleteService, BulkDeleteResponse>() {
ServerRpcController controller = new ServerRpcController();
BlockingRpcCallback<BulkDeleteResponse> rpcCallback =
new BlockingRpcCallback<BulkDeleteResponse>();
public BulkDeleteResponse call(BulkDeleteService service) throws IOException {
Builder builder = BulkDeleteRequest.newBuilder();
builder.setScan(ProtobufUtil.toScan(scan));
builder.setDeleteType(DeleteType.VERSION);
builder.setRowBatchSize(rowBatchSize);
// Set optional timestamp if needed
builder.setTimestamp(timeStamp);
service.delete(controller, builder.build(), rpcCallback);
return rpcCallback.get();
}
};
Map<byte[], BulkDeleteResponse> result = ht.coprocessorService(BulkDeleteService.class, scan
.getStartRow(), scan.getStopRow(), callable);
for (BulkDeleteResponse response : result.values()) {
noOfDeletedRows += response.getRowsDeleted();
}
Modifier and Type | Class and Description |
---|---|
private static class |
BulkDeleteEndpoint.Column |
org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteService.BlockingInterface, org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteService.Interface, org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteService.Stub
Coprocessor.State
Modifier and Type | Field and Description |
---|---|
private RegionCoprocessorEnvironment |
env |
private static org.apache.commons.logging.Log |
LOG |
private static String |
NO_OF_VERSIONS_TO_DELETE |
PRIORITY_HIGHEST, PRIORITY_LOWEST, PRIORITY_SYSTEM, PRIORITY_USER, VERSION
Constructor and Description |
---|
BulkDeleteEndpoint() |
Modifier and Type | Method and Description |
---|---|
private Delete |
createDeleteMutation(List<Cell> deleteRow,
org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteRequest.DeleteType deleteType,
Long timestamp) |
void |
delete(com.google.protobuf.RpcController controller,
org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteRequest request,
com.google.protobuf.RpcCallback<org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteResponse> done)
rpc delete(.BulkDeleteRequest) returns (.BulkDeleteResponse); |
com.google.protobuf.Service |
getService() |
void |
start(CoprocessorEnvironment env) |
void |
stop(CoprocessorEnvironment env) |
private static final String NO_OF_VERSIONS_TO_DELETE
private static final org.apache.commons.logging.Log LOG
private RegionCoprocessorEnvironment env
public com.google.protobuf.Service getService()
getService
in interface CoprocessorService
public void delete(com.google.protobuf.RpcController controller, org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteRequest request, com.google.protobuf.RpcCallback<org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteResponse> done)
org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteService
rpc delete(.BulkDeleteRequest) returns (.BulkDeleteResponse);
delete
in class org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteService
private Delete createDeleteMutation(List<Cell> deleteRow, org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteRequest.DeleteType deleteType, Long timestamp)
public void start(CoprocessorEnvironment env) throws IOException
start
in interface Coprocessor
IOException
public void stop(CoprocessorEnvironment env) throws IOException
stop
in interface Coprocessor
IOException
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.