Package kala.compress.compressors.snappy
Class FramedSnappyCompressorOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- kala.compress.compressors.CompressorOutputStream<java.io.OutputStream>
-
- kala.compress.compressors.snappy.FramedSnappyCompressorOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class FramedSnappyCompressorOutputStream extends CompressorOutputStream<java.io.OutputStream>
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
Fields Modifier and Type Field Description private byte[]bufferprivate PureJavaCrc32Cchecksumprivate ByteUtils.ByteConsumerconsumerprivate intcurrentIndexprivate static intMAX_COMPRESSED_BUFFER_SIZEprivate byte[]oneByteprivate Parametersparams
-
Constructor Summary
Constructors Constructor Description FramedSnappyCompressorOutputStream(java.io.OutputStream out)Constructs a new output stream that compresses snappy-framed-compressed data to the specified output stream.FramedSnappyCompressorOutputStream(java.io.OutputStream out, Parameters params)Constructs a new output stream that compresses snappy-framed-compressed data to the specified output stream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidfinish()Compresses all remaining data and writes it to the stream, doesn't close the underlying stream.private voidflushBuffer()(package private) static longmask(long x)voidwrite(byte[] data, int off, int len)voidwrite(int b)private voidwriteCrc()private voidwriteLittleEndian(int numBytes, long num)-
Methods inherited from class kala.compress.compressors.CompressorOutputStream
out
-
-
-
-
Field Detail
-
MAX_COMPRESSED_BUFFER_SIZE
private static final int MAX_COMPRESSED_BUFFER_SIZE
- See Also:
- Constant Field Values
-
params
private final Parameters params
-
checksum
private final PureJavaCrc32C checksum
-
oneByte
private final byte[] oneByte
-
buffer
private final byte[] buffer
-
currentIndex
private int currentIndex
-
consumer
private final ByteUtils.ByteConsumer consumer
-
-
Constructor Detail
-
FramedSnappyCompressorOutputStream
public FramedSnappyCompressorOutputStream(java.io.OutputStream out) throws java.io.IOExceptionConstructs a new output stream that compresses snappy-framed-compressed data to the specified output stream.- Parameters:
out- the OutputStream to which to write the compressed data- Throws:
java.io.IOException- if writing the signature fails
-
FramedSnappyCompressorOutputStream
public FramedSnappyCompressorOutputStream(java.io.OutputStream out, Parameters params) throws java.io.IOExceptionConstructs a new output stream that compresses snappy-framed-compressed data to the specified output stream.- Parameters:
out- the OutputStream to which to write the compressed dataparams- parameters used to fine-tune compression, in particular to balance compression ratio vs compression speed.- Throws:
java.io.IOException- if writing the signature fails
-
-
Method Detail
-
mask
static long mask(long x)
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
finish
public void finish() throws java.io.IOExceptionCompresses all remaining data and writes it to the stream, doesn't close the underlying stream.- Throws:
java.io.IOException- if an error occurs
-
flushBuffer
private void flushBuffer() throws java.io.IOException- Throws:
java.io.IOException
-
write
public void write(byte[] data, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
write
public void write(int b) throws java.io.IOException- Overrides:
writein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
writeCrc
private void writeCrc() throws java.io.IOException- Throws:
java.io.IOException
-
writeLittleEndian
private void writeLittleEndian(int numBytes, long num) throws java.io.IOException- Throws:
java.io.IOException
-
-