Class DeflateCompressor
java.lang.Object
org.elasticsearch.common.compress.DeflateCompressor
- All Implemented Interfaces:
Compressor
public class DeflateCompressor extends java.lang.Object implements Compressor
Compressor
implementation based on the DEFLATE compression algorithm.-
Constructor Summary
Constructors Constructor Description DeflateCompressor()
-
Method Summary
Modifier and Type Method Description BytesReference
compress(BytesReference bytesReference)
Compress bytes into a newly allocated buffer.int
headerLength()
static java.io.InputStream
inputStream(java.io.InputStream in, boolean threadLocal)
Creates a new input stream that decompresses the contents read from the provided input stream.boolean
isCompressed(BytesReference bytes)
java.io.InputStream
threadLocalInputStream(java.io.InputStream in)
Creates a new input stream that decompresses the contents read from the provided input stream.java.io.OutputStream
threadLocalOutputStream(java.io.OutputStream out)
Creates a new output stream that compresses the contents and writes to the provided output stream.BytesReference
uncompress(BytesReference bytesReference)
Decompress bytes into a newly allocated buffer.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
DeflateCompressor
public DeflateCompressor()
-
-
Method Details
-
isCompressed
- Specified by:
isCompressed
in interfaceCompressor
-
headerLength
public int headerLength()- Specified by:
headerLength
in interfaceCompressor
-
threadLocalInputStream
public java.io.InputStream threadLocalInputStream(java.io.InputStream in) throws java.io.IOExceptionDescription copied from interface:Compressor
Creates a new input stream that decompresses the contents read from the provided input stream. Closing the returnedInputStream
will close the provided stream input. Note: The returned stream may only be used on the thread that created it as it might use thread-local resources and must be safely closed after use- Specified by:
threadLocalInputStream
in interfaceCompressor
- Throws:
java.io.IOException
-
inputStream
public static java.io.InputStream inputStream(java.io.InputStream in, boolean threadLocal) throws java.io.IOExceptionCreates a new input stream that decompresses the contents read from the provided input stream. Closing the returned stream will close the provided input stream. Optionally uses thread-local, pooled resources to save off-heap allocations if the stream is guaranteed to not escape the current thread.- Parameters:
in
- input stream to wrapthreadLocal
- whether this stream will only be used on the current thread or not- Returns:
- decompressing stream
- Throws:
java.io.IOException
-
threadLocalOutputStream
public java.io.OutputStream threadLocalOutputStream(java.io.OutputStream out) throws java.io.IOExceptionDescription copied from interface:Compressor
Creates a new output stream that compresses the contents and writes to the provided output stream. Closing the returnedOutputStream
will close the provided output stream. Note: The returned stream may only be used on the thread that created it as it might use thread-local resources and must be safely closed after use- Specified by:
threadLocalOutputStream
in interfaceCompressor
- Throws:
java.io.IOException
-
uncompress
Description copied from interface:Compressor
Decompress bytes into a newly allocated buffer.- Specified by:
uncompress
in interfaceCompressor
- Parameters:
bytesReference
- bytes to decompress- Returns:
- decompressed bytes
- Throws:
java.io.IOException
-
compress
Description copied from interface:Compressor
Compress bytes into a newly allocated buffer.- Specified by:
compress
in interfaceCompressor
- Parameters:
bytesReference
- bytes to compress- Returns:
- compressed bytes
- Throws:
java.io.IOException
-