Package org.xerial.snappy
Class SnappyFramedInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.xerial.snappy.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- Since:
- 1.1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSnappyFramedInputStream.FrameDatastatic classSnappyFramedInputStream.FrameMetaData
-
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 intavailable()voidclose()booleanisOpen()intread()intread(byte[] output, int offset, int length)intread(java.nio.ByteBuffer dst)longtransferTo(java.io.OutputStream os)Transfers the entire content of thisInputStreamto os.longtransferTo(java.nio.channels.WritableByteChannel wbc)Transfers the entire content of thisReadableByteChannelto wbc.
-
-
-
Constructor Detail
-
SnappyFramedInputStream
public SnappyFramedInputStream(java.io.InputStream in) throws java.io.IOExceptionCreates a Snappy input stream to read data from the specified underlying input stream.Uses
DefaultPoolFactoryto obtainBufferPoolfor buffers.- Parameters:
in- the underlying input stream. Must not benull.- Throws:
java.io.IOException
-
SnappyFramedInputStream
public SnappyFramedInputStream(java.io.InputStream in, BufferPool bufferPool) throws java.io.IOExceptionCreates a Snappy input stream to read data from the specified underlying input stream.- Parameters:
in- the underlying input stream. Must not benull.bufferPool- Used to obtain buffer instances. Must not benull.- Throws:
java.io.IOException
-
SnappyFramedInputStream
public SnappyFramedInputStream(java.io.InputStream in, boolean verifyChecksums) throws java.io.IOExceptionCreates a Snappy input stream to read data from the specified underlying input stream.Uses
DefaultPoolFactoryto obtainBufferPoolfor buffers.- Parameters:
in- the underlying input stream. Must not benull.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.IOExceptionCreates a Snappy input stream to read data from the specified underlying input stream.- Parameters:
in- the underlying input stream. Must not benull.verifyChecksums- if true, checksums in input stream will be verifiedbufferPool- Used to obtain buffer instances. Must not benull.- Throws:
java.io.IOException
-
SnappyFramedInputStream
public SnappyFramedInputStream(java.nio.channels.ReadableByteChannel in, BufferPool bufferPool) throws java.io.IOExceptionCreates a Snappy input stream to read data from the specified underlying channel.- Parameters:
in- the underlying readable channel. Must not benull.bufferPool- Used to obtain buffer instances. Must not benull.- Throws:
java.io.IOException
-
SnappyFramedInputStream
public SnappyFramedInputStream(java.nio.channels.ReadableByteChannel in) throws java.io.IOExceptionCreates a Snappy input stream to read data from the specified underlying channel.Uses
DefaultPoolFactoryto obtainBufferPoolfor buffers.- Parameters:
in- the underlying readable channel. Must not benull.- Throws:
java.io.IOException
-
SnappyFramedInputStream
public SnappyFramedInputStream(java.nio.channels.ReadableByteChannel in, boolean verifyChecksums) throws java.io.IOExceptionCreates a Snappy input stream to read data from the specified underlying channel.Uses
DefaultPoolFactoryto obtainBufferPoolfor buffers.- Parameters:
in- the underlying readable channel. Must not benull.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.IOExceptionCreates a Snappy input stream to read data from the specified underlying channel.- Parameters:
in- the underlying readable channel. Must not benull.verifyChecksums- if true, checksums in input stream will be verifiedbufferPool- Used to obtain buffer instances. Must not benull.- Throws:
java.io.IOException
-
-
Method Detail
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] output, int offset, int length) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException- Overrides:
availablein classjava.io.InputStream- Throws:
java.io.IOException
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin interfacejava.nio.channels.Channel
-
read
public int read(java.nio.ByteBuffer dst) throws java.io.IOException- Specified by:
readin interfacejava.nio.channels.ReadableByteChannel- Throws:
java.io.IOException
-
transferTo
public long transferTo(java.io.OutputStream os) throws java.io.IOExceptionTransfers the entire content of thisInputStreamto 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 of0.- Overrides:
transferToin classjava.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.IOExceptionTransfers the entire content of thisReadableByteChannelto 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 of0.- 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:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.nio.channels.Channel- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
-