Search in sources :

Example 6 with CellScannable

use of org.apache.hadoop.hbase.CellScannable in project hbase by apache.

the class MockRegionServer method scan.

@Override
public ScanResponse scan(RpcController controller, ScanRequest request) throws ServiceException {
    ScanResponse.Builder builder = ScanResponse.newBuilder();
    try {
        if (request.hasScan()) {
            byte[] regionName = request.getRegion().getValue().toByteArray();
            builder.setScannerId(openScanner(regionName, null));
            builder.setMoreResults(true);
        } else {
            long scannerId = request.getScannerId();
            Result result = next(scannerId);
            if (result != null) {
                builder.addCellsPerResult(result.size());
                List<CellScannable> results = new ArrayList<>(1);
                results.add(result);
                ((HBaseRpcController) controller).setCellScanner(CellUtil.createCellScanner(results));
                builder.setMoreResults(true);
            } else {
                builder.setMoreResults(false);
                close(scannerId);
            }
        }
    } catch (IOException ie) {
        throw new ServiceException(ie);
    }
    return builder.build();
}
Also used : CellScannable(org.apache.hadoop.hbase.CellScannable) HBaseRpcController(org.apache.hadoop.hbase.ipc.HBaseRpcController) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) ScanResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanResponse) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Result(org.apache.hadoop.hbase.client.Result)

Aggregations

CellScannable (org.apache.hadoop.hbase.CellScannable)6 ArrayList (java.util.ArrayList)5 IOException (java.io.IOException)4 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)4 HBaseRpcController (org.apache.hadoop.hbase.ipc.HBaseRpcController)4 ClientProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos)4 List (java.util.List)3 Map (java.util.Map)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 IdentityHashMap (java.util.IdentityHashMap)2 Optional (java.util.Optional)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)2 TimeUnit (java.util.concurrent.TimeUnit)2 Supplier (java.util.function.Supplier)2 Collectors (java.util.stream.Collectors)2