Class Lz4BlockCompressor
java.lang.Object
org.apache.flink.runtime.io.compression.Lz4BlockCompressor
- All Implemented Interfaces:
BlockCompressor
Encode data into LZ4 format (not compatible with the LZ4 Frame format). It reads from and writes
to byte arrays provided from the outside, thus reducing copy time.
This class is copied and modified from LZ4BlockOutputStream.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcompress(byte[] src, int srcOff, int srcLen, byte[] dst, int dstOff) Compress data read from src, and write the compressed data to dst.intcompress(ByteBuffer src, int srcOff, int srcLen, ByteBuffer dst, int dstOff) Compress source data read from (Buffer.position()+srcOff), and write the compressed data to dst.intgetMaxCompressedSize(int srcSize) Get the max compressed size for a given original size.
-
Constructor Details
-
Lz4BlockCompressor
public Lz4BlockCompressor()
-
-
Method Details
-
getMaxCompressedSize
public int getMaxCompressedSize(int srcSize) Description copied from interface:BlockCompressorGet the max compressed size for a given original size.- Specified by:
getMaxCompressedSizein interfaceBlockCompressor
-
compress
public int compress(ByteBuffer src, int srcOff, int srcLen, ByteBuffer dst, int dstOff) throws BufferCompressionException Description copied from interface:BlockCompressorCompress source data read from (Buffer.position()+srcOff), and write the compressed data to dst.- Specified by:
compressin interfaceBlockCompressor- Parameters:
src- Uncompressed data to read fromsrcOff- The start offset of uncompressed datasrcLen- The length of data which want to be compresseddst- The target to write compressed datadstOff- The start offset to write the compressed data- Returns:
- Length of compressed data
- Throws:
BufferCompressionException- if exception thrown when compressing
-
compress
public int compress(byte[] src, int srcOff, int srcLen, byte[] dst, int dstOff) throws BufferCompressionException Description copied from interface:BlockCompressorCompress data read from src, and write the compressed data to dst.- Specified by:
compressin interfaceBlockCompressor- Parameters:
src- Uncompressed data to read fromsrcOff- The start offset of uncompressed datasrcLen- The length of data which want to be compresseddst- The target to write compressed datadstOff- The start offset to write the compressed data- Returns:
- Length of compressed data
- Throws:
BufferCompressionException- if exception thrown when compressing
-