如何在hbase中批量删除多行?
我在hbase表“mytable”中有以下带有这些键的行
user_1
user_2
user_3
...
user_9999999
我想使用Hbase shell从中删除行:
user_500到user_900
我知道没有办法删除,但是有没有办法使用“批量删除处理器”来执行此操作?
我在这里看到:
我只想粘贴导入,然后将其粘贴到shell中,但不知道如何进行此操作。有谁知道我如何从jruby hbase shell使用这个端点?
Table ht = TEST_UTIL.getConnection().getTable("my_table");
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);
builder.setRowBatchSize(rowBatchSize);
if (timeStamp != null) {
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();
}
ht.close();
如果没有办法通过JRuby做到这一点,Java或替代方法来快速删除多行是可以的。