use of org.apache.hadoop.io.compress.lz4.Lz4Compressor in project druid by druid-io.
the class LZ4Transcoder method compress.
@Override
protected byte[] compress(byte[] in) {
if (in == null) {
throw new NullPointerException("Can't compress null");
}
LZ4Compressor compressor = lz4Factory.fastCompressor();
byte[] out = new byte[compressor.maxCompressedLength(in.length)];
int compressedLength = compressor.compress(in, 0, in.length, out, 0);
getLogger().debug("Compressed %d bytes to %d", in.length, compressedLength);
return ByteBuffer.allocate(Integer.BYTES + compressedLength).putInt(in.length).put(out, 0, compressedLength).array();
}
use of org.apache.hadoop.io.compress.lz4.Lz4Compressor in project ignite by apache.
the class CompressionProcessorImpl method compressPageLz4.
/**
* @param compactPage Compacted page.
* @param compactSize Compacted page size.
* @param compressLevel Compression level.
* @return Compressed page.
*/
private ByteBuffer compressPageLz4(ByteBuffer compactPage, int compactSize, int compressLevel) {
LZ4Compressor compressor = Lz4.getCompressor(compressLevel);
ByteBuffer compressedPage = compressBuf.get();
copyPageHeader(compactPage, compressedPage, compactSize);
compressor.compress(compactPage, compressedPage);
compactPage.flip();
compressedPage.flip();
return compressedPage;
}
Aggregations