Class SnappyCompressorInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, InputStreamStatistics

    public class SnappyCompressorInputStream
    extends AbstractLZ77CompressorInputStream
    CompressorInputStream for the raw Snappy format.

    This implementation uses an internal buffer in order to handle the back-references that are at the heart of the LZ77 algorithm. The size of the buffer must be at least as big as the biggest offset used in the compressed stream. The current version of the Snappy algorithm as defined by Google works on 32k blocks and doesn't contain offsets bigger than 32k which is the default block size used by this class.

    Since:
    1.7
    See Also:
    Snappy compressed format description
    • Field Detail

      • DEFAULT_BLOCK_SIZE

        public static final int DEFAULT_BLOCK_SIZE
        Default block size
        See Also:
        Constant Field Values
    • Constructor Detail

      • SnappyCompressorInputStream

        public SnappyCompressorInputStream​(java.io.InputStream is)
                                    throws java.io.IOException
        Constructor using the default buffer size of 32k.
        Parameters:
        is - An InputStream to read compressed data from
        Throws:
        java.io.IOException - if reading fails
      • SnappyCompressorInputStream

        public SnappyCompressorInputStream​(java.io.InputStream is,
                                           int blockSize)
                                    throws java.io.IOException
        Constructor using a configurable buffer size.
        Parameters:
        is - An InputStream to read compressed data from
        blockSize - The block size used in compression
        Throws:
        java.io.IOException - if reading fails
        java.lang.IllegalArgumentException - if blockSize is not bigger than 0
    • Method Detail

      • read

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException