Package org.apache.parquet.hadoop.codec
Class NonBlockedCompressor
java.lang.Object
org.apache.parquet.hadoop.codec.NonBlockedCompressor
- All Implemented Interfaces:
org.apache.hadoop.io.compress.Compressor
- Direct Known Subclasses:
Lz4RawCompressor,SnappyCompressor
public abstract class NonBlockedCompressor
extends Object
implements org.apache.hadoop.io.compress.Compressor
This class is a wrapper around the underlying compressor. It always consumes
the entire input in setInput and compresses it as one compressed block.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcompress(byte[] buffer, int off, int len) Fills specified buffer with compressed data.protected abstract intcompress(ByteBuffer uncompressed, ByteBuffer compressed) Compress the content in the given input buffer.voidend()voidfinish()booleanfinished()longlongprotected abstract intmaxCompressedLength(int byteSize) Get the maximum byte size needed for compressing data of the given byte size.booleanvoidreinit(org.apache.hadoop.conf.Configuration c) voidreset()voidsetDictionary(byte[] dictionary, int off, int len) voidsetInput(byte[] buffer, int off, int len)
-
Constructor Details
-
NonBlockedCompressor
public NonBlockedCompressor()
-
-
Method Details
-
compress
Fills specified buffer with compressed data. Returns actual number of bytes of compressed data. A return value of 0 indicates that needsInput() should be called in order to determine if more input data is required.- Specified by:
compressin interfaceorg.apache.hadoop.io.compress.Compressor- Parameters:
buffer- Buffer for the compressed dataoff- Start offset of the datalen- Size of the buffer- Returns:
- The actual number of bytes of compressed data.
- Throws:
IOException
-
setInput
public void setInput(byte[] buffer, int off, int len) - Specified by:
setInputin interfaceorg.apache.hadoop.io.compress.Compressor
-
end
public void end()- Specified by:
endin interfaceorg.apache.hadoop.io.compress.Compressor
-
finish
public void finish()- Specified by:
finishin interfaceorg.apache.hadoop.io.compress.Compressor
-
finished
public boolean finished()- Specified by:
finishedin interfaceorg.apache.hadoop.io.compress.Compressor
-
getBytesRead
public long getBytesRead()- Specified by:
getBytesReadin interfaceorg.apache.hadoop.io.compress.Compressor
-
getBytesWritten
public long getBytesWritten()- Specified by:
getBytesWrittenin interfaceorg.apache.hadoop.io.compress.Compressor
-
needsInput
public boolean needsInput()- Specified by:
needsInputin interfaceorg.apache.hadoop.io.compress.Compressor
-
reinit
public void reinit(org.apache.hadoop.conf.Configuration c) - Specified by:
reinitin interfaceorg.apache.hadoop.io.compress.Compressor
-
reset
public void reset()- Specified by:
resetin interfaceorg.apache.hadoop.io.compress.Compressor
-
setDictionary
public void setDictionary(byte[] dictionary, int off, int len) - Specified by:
setDictionaryin interfaceorg.apache.hadoop.io.compress.Compressor
-
maxCompressedLength
protected abstract int maxCompressedLength(int byteSize) Get the maximum byte size needed for compressing data of the given byte size.- Parameters:
byteSize- byte size of the data to compress- Returns:
- maximum byte size of the compressed data
-
compress
Compress the content in the given input buffer. After the compression, you can retrieve the compressed data from the output buffer [pos() ... limit()) (compressed data size = limit() - pos() = remaining())- Parameters:
uncompressed- buffer[pos() ... limit()) containing the input datacompressed- output of the compressed data. Uses range [pos()..].- Returns:
- byte size of the compressed data.
- Throws:
IOException
-