Class SnappyFramedInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.nio.channels.Channel, java.nio.channels.ReadableByteChannel

    public final class SnappyFramedInputStream
    extends java.io.InputStream
    implements java.nio.channels.ReadableByteChannel
    Implements the x-snappy-framed as an InputStream and ReadableByteChannel.
    Since:
    1.1.0
    • Constructor Summary

      Constructors 
      Constructor Description
      SnappyFramedInputStream​(java.io.InputStream in)
      Creates a Snappy input stream to read data from the specified underlying input stream.
      SnappyFramedInputStream​(java.io.InputStream in, boolean verifyChecksums)
      Creates a Snappy input stream to read data from the specified underlying input stream.
      SnappyFramedInputStream​(java.io.InputStream in, boolean verifyChecksums, BufferPool bufferPool)
      Creates a Snappy input stream to read data from the specified underlying input stream.
      SnappyFramedInputStream​(java.io.InputStream in, BufferPool bufferPool)
      Creates a Snappy input stream to read data from the specified underlying input stream.
      SnappyFramedInputStream​(java.nio.channels.ReadableByteChannel in)
      Creates a Snappy input stream to read data from the specified underlying channel.
      SnappyFramedInputStream​(java.nio.channels.ReadableByteChannel in, boolean verifyChecksums)
      Creates a Snappy input stream to read data from the specified underlying channel.
      SnappyFramedInputStream​(java.nio.channels.ReadableByteChannel in, boolean verifyChecksums, BufferPool bufferPool)
      Creates a Snappy input stream to read data from the specified underlying channel.
      SnappyFramedInputStream​(java.nio.channels.ReadableByteChannel in, BufferPool bufferPool)
      Creates a Snappy input stream to read data from the specified underlying channel.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()  
      void close()  
      boolean isOpen()
      int read()  
      int read​(byte[] output, int offset, int length)  
      int read​(java.nio.ByteBuffer dst)
      long transferTo​(java.io.OutputStream os)
      Transfers the entire content of this InputStream to os.
      long transferTo​(java.nio.channels.WritableByteChannel wbc)
      Transfers the entire content of this ReadableByteChannel to wbc.
      • Methods inherited from class java.io.InputStream

        mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SnappyFramedInputStream

        public SnappyFramedInputStream​(java.io.InputStream in)
                                throws java.io.IOException
        Creates a Snappy input stream to read data from the specified underlying input stream.

        Uses DefaultPoolFactory to obtain BufferPool for buffers.

        Parameters:
        in - the underlying input stream. Must not be null.
        Throws:
        java.io.IOException
      • SnappyFramedInputStream

        public SnappyFramedInputStream​(java.io.InputStream in,
                                       BufferPool bufferPool)
                                throws java.io.IOException
        Creates a Snappy input stream to read data from the specified underlying input stream.
        Parameters:
        in - the underlying input stream. Must not be null.
        bufferPool - Used to obtain buffer instances. Must not be null.
        Throws:
        java.io.IOException
      • SnappyFramedInputStream

        public SnappyFramedInputStream​(java.io.InputStream in,
                                       boolean verifyChecksums)
                                throws java.io.IOException
        Creates a Snappy input stream to read data from the specified underlying input stream.

        Uses DefaultPoolFactory to obtain BufferPool for buffers.

        Parameters:
        in - the underlying input stream. Must not be null.
        verifyChecksums - if true, checksums in input stream will be verified
        Throws:
        java.io.IOException
      • SnappyFramedInputStream

        public SnappyFramedInputStream​(java.io.InputStream in,
                                       boolean verifyChecksums,
                                       BufferPool bufferPool)
                                throws java.io.IOException
        Creates a Snappy input stream to read data from the specified underlying input stream.
        Parameters:
        in - the underlying input stream. Must not be null.
        verifyChecksums - if true, checksums in input stream will be verified
        bufferPool - Used to obtain buffer instances. Must not be null.
        Throws:
        java.io.IOException
      • SnappyFramedInputStream

        public SnappyFramedInputStream​(java.nio.channels.ReadableByteChannel in,
                                       BufferPool bufferPool)
                                throws java.io.IOException
        Creates a Snappy input stream to read data from the specified underlying channel.
        Parameters:
        in - the underlying readable channel. Must not be null.
        bufferPool - Used to obtain buffer instances. Must not be null.
        Throws:
        java.io.IOException
      • SnappyFramedInputStream

        public SnappyFramedInputStream​(java.nio.channels.ReadableByteChannel in)
                                throws java.io.IOException
        Creates a Snappy input stream to read data from the specified underlying channel.

        Uses DefaultPoolFactory to obtain BufferPool for buffers.

        Parameters:
        in - the underlying readable channel. Must not be null.
        Throws:
        java.io.IOException
      • SnappyFramedInputStream

        public SnappyFramedInputStream​(java.nio.channels.ReadableByteChannel in,
                                       boolean verifyChecksums)
                                throws java.io.IOException
        Creates a Snappy input stream to read data from the specified underlying channel.

        Uses DefaultPoolFactory to obtain BufferPool for buffers.

        Parameters:
        in - the underlying readable channel. Must not be null.
        verifyChecksums - if true, checksums in input stream will be verified
        Throws:
        java.io.IOException
      • SnappyFramedInputStream

        public SnappyFramedInputStream​(java.nio.channels.ReadableByteChannel in,
                                       boolean verifyChecksums,
                                       BufferPool bufferPool)
                                throws java.io.IOException
        Creates a Snappy input stream to read data from the specified underlying channel.
        Parameters:
        in - the underlying readable channel. Must not be null.
        verifyChecksums - if true, checksums in input stream will be verified
        bufferPool - Used to obtain buffer instances. Must not be null.
        Throws:
        java.io.IOException
    • Method Detail

      • read

        public int read()
                 throws java.io.IOException
        Specified by:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] output,
                        int offset,
                        int length)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • available

        public int available()
                      throws java.io.IOException
        Overrides:
        available in class java.io.InputStream
        Throws:
        java.io.IOException
      • isOpen

        public boolean isOpen()
        Specified by:
        isOpen in interface java.nio.channels.Channel
      • read

        public int read​(java.nio.ByteBuffer dst)
                 throws java.io.IOException
        Specified by:
        read in interface java.nio.channels.ReadableByteChannel
        Throws:
        java.io.IOException
      • transferTo

        public long transferTo​(java.io.OutputStream os)
                        throws java.io.IOException
        Transfers the entire content of this InputStream to os. This potentially limits the amount of buffering required to decompress content.

        Unlike read(byte[], int, int), this method does not need to be called multiple times. A single call will transfer all available content. Any calls after the source has been exhausted will result in a return value of 0.

        Overrides:
        transferTo in class java.io.InputStream
        Parameters:
        os - The destination to write decompressed content to.
        Returns:
        The number of bytes transferred.
        Throws:
        java.io.IOException
        Since:
        1.1.1
      • transferTo

        public long transferTo​(java.nio.channels.WritableByteChannel wbc)
                        throws java.io.IOException
        Transfers the entire content of this ReadableByteChannel to wbc. This potentially limits the amount of buffering required to decompress content.

        Unlike read(ByteBuffer), this method does not need to be called multiple times. A single call will transfer all available content. Any calls after the source has been exhausted will result in a return value of 0.

        Parameters:
        wbc - The destination to write decompressed content to.
        Returns:
        The number of bytes transferred.
        Throws:
        java.io.IOException
        Since:
        1.1.1
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.nio.channels.Channel
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.InputStream
        Throws:
        java.io.IOException