/** * Do the compression. * @return Compressed byte buffer. */ public byte[] doCompressData() { compressedStream.reset(); DataOutputStream dataOut = new DataOutputStream(compressedStream); try { this.dataBlockEncoder.compressKeyValues( dataOut, getUncompressedBuffer(), includesMemstoreTS); } catch (IOException e) { throw new RuntimeException(String.format( "Bug in decoding part of algorithm %s. " + "Probably it requested more bytes than are available.", toString()), e); } return compressedStream.toByteArray(); }
private ByteBuffer encodeBufferToHFileBlockBuffer(ByteBuffer in, DataBlockEncoding algo, boolean includesMemstoreTS, byte[] dummyHeader) { ByteArrayOutputStream encodedStream = new ByteArrayOutputStream(); DataOutputStream dataOut = new DataOutputStream(encodedStream); DataBlockEncoder encoder = algo.getEncoder(); try { encodedStream.write(dummyHeader); algo.writeIdInBytes(dataOut); encoder.compressKeyValues(dataOut, in, includesMemstoreTS); } catch (IOException e) { throw new RuntimeException(String.format("Bug in data block encoder " + "'%s', it probably requested too much data", algo.toString()), e); } return ByteBuffer.wrap(encodedStream.toByteArray()); }