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

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

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

      public java.io.InputStream threadLocalInputStream​(java.io.InputStream in) throws java.io.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:
      java.io.IOException
    • inputStream

      public static java.io.InputStream inputStream​(java.io.InputStream in, boolean threadLocal) throws java.io.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:
      java.io.IOException
    • threadLocalOutputStream

      public java.io.OutputStream threadLocalOutputStream​(java.io.OutputStream out) throws java.io.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:
      java.io.IOException
    • uncompress

      public BytesReference uncompress​(BytesReference bytesReference) throws java.io.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:
      java.io.IOException
    • compress

      public BytesReference compress​(BytesReference bytesReference) throws java.io.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:
      java.io.IOException