org.apache.kafka.common.message
Class KafkaLZ4BlockOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by org.apache.kafka.common.message.KafkaLZ4BlockOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public final class KafkaLZ4BlockOutputStream
extends java.io.FilterOutputStream

A partial implementation of the v1.4.1 LZ4 Frame format.

See Also:
LZ4 Framing Format Spec

Nested Class Summary
static class KafkaLZ4BlockOutputStream.BD
           
static class KafkaLZ4BlockOutputStream.FLG
           
 
Field Summary
static int BLOCKSIZE_1MB
           
static int BLOCKSIZE_256KB
           
static int BLOCKSIZE_4MB
           
static int BLOCKSIZE_64KB
           
static java.lang.String CLOSED_STREAM
           
static int LZ4_FRAME_INCOMPRESSIBLE_MASK
           
static int LZ4_MAX_HEADER_LENGTH
           
static int MAGIC
           
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
KafkaLZ4BlockOutputStream(java.io.OutputStream out)
          Create a new OutputStream that will compress data using the LZ4 algorithm.
KafkaLZ4BlockOutputStream(java.io.OutputStream out, int blockSize)
          Create a new OutputStream that will compress data using the LZ4 algorithm.
KafkaLZ4BlockOutputStream(java.io.OutputStream out, int blockSize, boolean blockChecksum)
          Create a new OutputStream that will compress data using the LZ4 algorithm.
 
Method Summary
 void close()
           
 void flush()
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.io.FilterOutputStream
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAGIC

public static final int MAGIC
See Also:
Constant Field Values

LZ4_MAX_HEADER_LENGTH

public static final int LZ4_MAX_HEADER_LENGTH
See Also:
Constant Field Values

LZ4_FRAME_INCOMPRESSIBLE_MASK

public static final int LZ4_FRAME_INCOMPRESSIBLE_MASK
See Also:
Constant Field Values

CLOSED_STREAM

public static final java.lang.String CLOSED_STREAM
See Also:
Constant Field Values

BLOCKSIZE_64KB

public static final int BLOCKSIZE_64KB
See Also:
Constant Field Values

BLOCKSIZE_256KB

public static final int BLOCKSIZE_256KB
See Also:
Constant Field Values

BLOCKSIZE_1MB

public static final int BLOCKSIZE_1MB
See Also:
Constant Field Values

BLOCKSIZE_4MB

public static final int BLOCKSIZE_4MB
See Also:
Constant Field Values
Constructor Detail

KafkaLZ4BlockOutputStream

public KafkaLZ4BlockOutputStream(java.io.OutputStream out,
                                 int blockSize,
                                 boolean blockChecksum)
                          throws java.io.IOException
Create a new OutputStream that will compress data using the LZ4 algorithm.

Parameters:
out - The output stream to compress
blockSize - Default: 4. The block size used during compression. 4=64kb, 5=256kb, 6=1mb, 7=4mb. All other values will generate an exception
blockChecksum - Default: false. When true, a XXHash32 checksum is computed and appended to the stream for every block of data
Throws:
java.io.IOException

KafkaLZ4BlockOutputStream

public KafkaLZ4BlockOutputStream(java.io.OutputStream out,
                                 int blockSize)
                          throws java.io.IOException
Create a new OutputStream that will compress data using the LZ4 algorithm.

Parameters:
out - The stream to compress
blockSize - Default: 4. The block size used during compression. 4=64kb, 5=256kb, 6=1mb, 7=4mb. All other values will generate an exception
Throws:
java.io.IOException

KafkaLZ4BlockOutputStream

public KafkaLZ4BlockOutputStream(java.io.OutputStream out)
                          throws java.io.IOException
Create a new OutputStream that will compress data using the LZ4 algorithm.

Parameters:
out - The output stream to compress
Throws:
java.io.IOException
Method Detail

write

public void write(int b)
           throws java.io.IOException
Overrides:
write in class java.io.FilterOutputStream
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Overrides:
write in class java.io.FilterOutputStream
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.FilterOutputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.FilterOutputStream
Throws:
java.io.IOException