Top Description Fields Constructors Methods
org.apache.commons.compress.compressors.snappy

public Class FramedSnappyCompressorOutputStream

extends CompressorOutputStream
Class Inheritance
Imports
java.io.ByteArrayOutputStream, .IOException, .OutputStream, org.apache.commons.codec.digest.PureJavaCrc32C, org.apache.commons.compress.compressors.CompressorOutputStream, org.apache.commons.compress.compressors.lz77support.Parameters, org.apache.commons.compress.utils.ByteUtils

CompressorOutputStream for the framing Snappy format.

Based on the "spec" in the version "Last revised: 2013-10-25"

Since
1.14
See Also
Snappy framing format description

Field Summary

Modifier and TypeField and Description
private final byte[]
private final PureJavaCrc32C
private final ByteUtils.ByteConsumer
private int
private static final int
private final byte[]
private final OutputStream
private final Parameters

Constructor Summary

AccessConstructor and Description
public
FramedSnappyCompressorOutputStream(final OutputStream
the OutputStream to which to write the compressed data
out
)

Constructs a new output stream that compresses snappy-framed-compressed data to the specified output stream.

public
FramedSnappyCompressorOutputStream(final OutputStream
the OutputStream to which to write the compressed data
out
,
final Parameters
parameters used to fine-tune compression, in particular to balance compression ratio vs compression speed.
params
)

Constructs a new output stream that compresses snappy-framed-compressed data to the specified output stream.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Closes this output stream and releases any system resources associated with this stream.
public void
finish()

Compresses all remaining data and writes it to the stream, doesn't close the underlying stream.

private void
pack-priv static long
mask(long x)

public void
write(final byte[]
the data.
data
,
int
the start offset in the data.
off
,
int
the number of bytes to write.
len
)

Overrides java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.
public void
write(final int
the byte.
b
)

Implements abstract java.io.OutputStream.write.

Writes the specified byte to this output stream.
private void
private void
writeLittleEndian(final int numBytes, final long num)

Field Detail

bufferback to summary
private final byte[] buffer
checksumback to summary
private final PureJavaCrc32C checksum
consumerback to summary
private final ByteUtils.ByteConsumer consumer
currentIndexback to summary
private int currentIndex
MAX_COMPRESSED_BUFFER_SIZEback to summary
private static final int MAX_COMPRESSED_BUFFER_SIZE
oneByteback to summary
private final byte[] oneByte
outback to summary
private final OutputStream out
paramsback to summary
private final Parameters params

Constructor Detail

FramedSnappyCompressorOutputStreamback to summary
public FramedSnappyCompressorOutputStream(final OutputStream out) throws IOException

Constructs a new output stream that compresses snappy-framed-compressed data to the specified output stream.

Parameters
out:OutputStream

the OutputStream to which to write the compressed data

Exceptions
IOException:
if writing the signature fails
FramedSnappyCompressorOutputStreamback to summary
public FramedSnappyCompressorOutputStream(final OutputStream out, final Parameters params) throws IOException

Constructs a new output stream that compresses snappy-framed-compressed data to the specified output stream.

Parameters
out:OutputStream

the OutputStream to which to write the compressed data

params:Parameters

parameters used to fine-tune compression, in particular to balance compression ratio vs compression speed.

Exceptions
IOException:
if writing the signature fails

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.OutputStream.close.

Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
finishback to summary
public void finish() throws IOException

Compresses all remaining data and writes it to the stream, doesn't close the underlying stream.

Exceptions
IOException:
if an error occurs
flushBufferback to summary
private void flushBuffer() throws IOException
maskback to summary
pack-priv static long mask(long x)
writeback to summary
public void write(final byte[] data, int off, int len) throws IOException

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation.

If b is null, a NullPointerException is thrown.

If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

Parameters
data:byte[]

the data.

off:int

the start offset in the data.

len:int

the number of bytes to write.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed.
writeback to summary
public void write(final int b) throws IOException

Implements abstract java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Parameters
b:int

the byte.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
writeCrcback to summary
private void writeCrc() throws IOException
writeLittleEndianback to summary
private void writeLittleEndian(final int numBytes, final long num) throws IOException