Class DeflateCompressor

java.lang.Object
org.elasticsearch.common.compress.DeflateCompressor
All Implemented Interfaces:
Compressor

public class DeflateCompressor extends Object implements Compressor
Compressor implementation based on the DEFLATE compression algorithm.
  • Constructor Details

    • DeflateCompressor

      public DeflateCompressor()
  • Method Details

    • isCompressed

      public boolean isCompressed(BytesReference bytes)
      Specified by:
      isCompressed in interface Compressor
    • headerLength

      public int headerLength()
      Specified by:
      headerLength in interface Compressor
    • threadLocalInputStream

      public InputStream threadLocalInputStream(InputStream in) throws IOException
      Description copied from interface: Compressor
      Creates a new input stream that decompresses the contents read from the provided input stream. Closing the returned InputStream 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 interface Compressor
      Throws:
      IOException
    • inputStream

      public static InputStream inputStream(InputStream in, boolean threadLocal) throws IOException
      Creates 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 wrap
      threadLocal - whether this stream will only be used on the current thread or not
      Returns:
      decompressing stream
      Throws:
      IOException
    • threadLocalOutputStream

      public OutputStream threadLocalOutputStream(OutputStream out) throws IOException
      Description copied from interface: Compressor
      Creates a new output stream that compresses the contents and writes to the provided output stream. Closing the returned OutputStream 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 interface Compressor
      Throws:
      IOException
    • uncompress

      public BytesReference uncompress(BytesReference bytesReference) throws IOException
      Description copied from interface: Compressor
      Decompress bytes into a newly allocated buffer.
      Specified by:
      uncompress in interface Compressor
      Parameters:
      bytesReference - bytes to decompress
      Returns:
      decompressed bytes
      Throws:
      IOException
    • compress

      public BytesReference compress(BytesReference bytesReference) throws IOException
      Description copied from interface: Compressor
      Compress bytes into a newly allocated buffer.
      Specified by:
      compress in interface Compressor
      Parameters:
      bytesReference - bytes to compress
      Returns:
      compressed bytes
      Throws:
      IOException