/** * @param codec to use for cellblock * @param cellBlock to encode * @return CellScanner to work against the content of <code>cellBlock</code> * @throws IOException if encoding fails */ public CellScanner createCellScanner(final Codec codec, final CompressionCodec compressor, final byte[] cellBlock) throws IOException { // Use this method from Client side to create the CellScanner if (compressor != null) { ByteBuffer cellBlockBuf = decompress(compressor, cellBlock); return codec.getDecoder(new ByteBufferInputStream(cellBlockBuf)); } // Not making the Decoder over the ByteBuffer purposefully. The Decoder over the BB will // make Cells directly over the passed BB. This method is called at client side and we don't // want the Cells to share the same byte[] where the RPC response is being read. Caching of any // of the Cells at user's app level will make it not possible to GC the response byte[] return codec.getDecoder(new ByteArrayInputStream(cellBlock)); }
/** * @return a byte stream reading the data + checksum of this block */ public DataInputStream getByteStream() { ByteBuffer dup = this.buf.duplicate(); dup.position(this.headerSize()); return new DataInputStream(new ByteBufferInputStream(dup)); }