Java Code Examples for org.apache.hadoop.hbase.CellUtil#createCellScanner()
The following examples show how to use
org.apache.hadoop.hbase.CellUtil#createCellScanner() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestProtobufRpcServiceImpl.java From hbase with Apache License 2.0 | 6 votes |
@Override public EchoResponseProto echo(RpcController controller, EchoRequestProto request) throws ServiceException { if (controller instanceof HBaseRpcController) { HBaseRpcController pcrc = (HBaseRpcController) controller; // If cells, scan them to check we are able to iterate what we were given and since this is an // echo, just put them back on the controller creating a new block. Tests our block building. CellScanner cellScanner = pcrc.cellScanner(); List<Cell> list = null; if (cellScanner != null) { list = new ArrayList<>(); try { while (cellScanner.advance()) { list.add(cellScanner.current()); } } catch (IOException e) { throw new ServiceException(e); } } cellScanner = CellUtil.createCellScanner(list); pcrc.setCellScanner(cellScanner); } return EchoResponseProto.newBuilder().setMessage(request.getMessage()).build(); }
Example 2
Source File: TestCellBlockBuilder.java From hbase with Apache License 2.0 | 6 votes |
static CellScanner getSizedCellScanner(final Cell[] cells) { int size = -1; for (Cell cell : cells) { size += PrivateCellUtil.estimatedSerializedSizeOf(cell); } final int totalSize = ClassSize.align(size); final CellScanner cellScanner = CellUtil.createCellScanner(cells); return new SizedCellScanner() { @Override public long heapSize() { return totalSize; } @Override public Cell current() { return cellScanner.current(); } @Override public boolean advance() throws IOException { return cellScanner.advance(); } }; }
Example 3
Source File: AbstractTestIPC.java From hbase with Apache License 2.0 | 5 votes |
/** * It is hard to verify the compression is actually happening under the wraps. Hope that if * unsupported, we'll get an exception out of some time (meantime, have to trace it manually to * confirm that compression is happening down in the client and server). */ @Test public void testCompressCellBlock() throws IOException, ServiceException { Configuration conf = new Configuration(HBaseConfiguration.create()); conf.set("hbase.client.rpc.compressor", GzipCodec.class.getCanonicalName()); List<Cell> cells = new ArrayList<>(); int count = 3; for (int i = 0; i < count; i++) { cells.add(CELL); } RpcServer rpcServer = createRpcServer(null, "testRpcServer", Lists.newArrayList(new RpcServer.BlockingServiceAndInterface( SERVICE, null)), new InetSocketAddress("localhost", 0), CONF, new FifoRpcScheduler(CONF, 1)); try (AbstractRpcClient<?> client = createRpcClient(conf)) { rpcServer.start(); BlockingInterface stub = newBlockingStub(client, rpcServer.getListenerAddress()); HBaseRpcController pcrc = new HBaseRpcControllerImpl(CellUtil.createCellScanner(cells)); String message = "hello"; assertEquals(message, stub.echo(pcrc, EchoRequestProto.newBuilder().setMessage(message).build()).getMessage()); int index = 0; CellScanner cellScanner = pcrc.cellScanner(); assertNotNull(cellScanner); while (cellScanner.advance()) { assertEquals(CELL, cellScanner.current()); index++; } assertEquals(count, index); } finally { rpcServer.stop(); } }
Example 4
Source File: TestCellBlockBuilder.java From hbase with Apache License 2.0 | 5 votes |
static void doBuildCellBlockUndoCellBlock(final CellBlockBuilder builder, final Codec codec, final CompressionCodec compressor, final int count, final int size, final boolean sized) throws IOException { Cell[] cells = getCells(count, size); CellScanner cellScanner = sized ? getSizedCellScanner(cells) : CellUtil.createCellScanner(Arrays.asList(cells).iterator()); ByteBuffer bb = builder.buildCellBlock(codec, compressor, cellScanner); cellScanner = builder.createCellScannerReusingBuffers(codec, compressor, new SingleByteBuff(bb)); int i = 0; while (cellScanner.advance()) { i++; } assertEquals(count, i); }
Example 5
Source File: Mutation.java From hbase with Apache License 2.0 | 4 votes |
@Override public CellScanner cellScanner() { return CellUtil.createCellScanner(getFamilyCellMap()); }
Example 6
Source File: HBaseRpcControllerImpl.java From hbase with Apache License 2.0 | 4 votes |
public HBaseRpcControllerImpl(final List<CellScannable> cellIterables) { this.cellScanner = cellIterables == null ? null : CellUtil.createCellScanner(cellIterables); }