/** * Gets the portion of the encoded byte array from an HBase table cell that has the avro-encoded * data payload. * * @param bytes The bytes from an HBase table cell. * @return the portion of the encoded byte array that contains the binary-encoded avro message. * @throws IOException on I/O error (eg. decoding error). */ public ByteBuffer getPayload(byte[] bytes) throws IOException { final ByteStreamArray byteStream = new ByteStreamArray(bytes); // Decode the writer schema and throw it away: mSchemaDecoder.decode(byteStream); return ByteBuffer.wrap(bytes, byteStream.getOffset(), bytes.length - byteStream.getOffset()); }
/** * Decodes the serialized bytes into a FijiCell. If reuse is non-null, the implementation may fill * it and return it as the FijiCell data payload. * * @param bytes The bytes from an HBase table cell. * @param reuse If non-null, may be filled with the decoded data and used as the data payload in * the return value. * @return The decoded FijiCell. * @throws IOException If there is an error. */ private DecodedCell<T> decode(byte[] bytes, T reuse) throws IOException { final ByteStreamArray byteStream = new ByteStreamArray(bytes); final Schema writerSchema = mSchemaDecoder.decode(byteStream); final Schema readerSchema = (mReaderSchema != null) ? mReaderSchema : writerSchema; final ByteBuffer binaryData = ByteBuffer.wrap(bytes, byteStream.getOffset(), bytes.length - byteStream.getOffset()); final T data = decodeAvro(binaryData, writerSchema, readerSchema, reuse); return new DecodedCell<T>(writerSchema, readerSchema, data); }