Search in sources :

Example 1 with KafkaLZ4BlockInputStream

use of org.apache.kafka.common.compress.KafkaLZ4BlockInputStream in project kafka by apache.

the class CompressionTypeTest method testLZ4FramingMagicV1.

@Test
public void testLZ4FramingMagicV1() {
    ByteBuffer buffer = ByteBuffer.allocate(256);
    KafkaLZ4BlockOutputStream out = (KafkaLZ4BlockOutputStream) CompressionType.LZ4.wrapForOutput(new ByteBufferOutputStream(buffer), RecordBatch.MAGIC_VALUE_V1);
    assertFalse(out.useBrokenFlagDescriptorChecksum());
    buffer.rewind();
    KafkaLZ4BlockInputStream in = (KafkaLZ4BlockInputStream) CompressionType.LZ4.wrapForInput(buffer, RecordBatch.MAGIC_VALUE_V1, BufferSupplier.create());
    assertFalse(in.ignoreFlagDescriptorChecksum());
}
Also used : ByteBufferOutputStream(org.apache.kafka.common.utils.ByteBufferOutputStream) KafkaLZ4BlockInputStream(org.apache.kafka.common.compress.KafkaLZ4BlockInputStream) KafkaLZ4BlockOutputStream(org.apache.kafka.common.compress.KafkaLZ4BlockOutputStream) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.jupiter.api.Test)

Example 2 with KafkaLZ4BlockInputStream

use of org.apache.kafka.common.compress.KafkaLZ4BlockInputStream in project kafka by apache.

the class CompressionTypeTest method testLZ4FramingMagicV0.

@Test
public void testLZ4FramingMagicV0() {
    ByteBuffer buffer = ByteBuffer.allocate(256);
    KafkaLZ4BlockOutputStream out = (KafkaLZ4BlockOutputStream) CompressionType.LZ4.wrapForOutput(new ByteBufferOutputStream(buffer), RecordBatch.MAGIC_VALUE_V0);
    assertTrue(out.useBrokenFlagDescriptorChecksum());
    buffer.rewind();
    KafkaLZ4BlockInputStream in = (KafkaLZ4BlockInputStream) CompressionType.LZ4.wrapForInput(buffer, RecordBatch.MAGIC_VALUE_V0, BufferSupplier.NO_CACHING);
    assertTrue(in.ignoreFlagDescriptorChecksum());
}
Also used : ByteBufferOutputStream(org.apache.kafka.common.utils.ByteBufferOutputStream) KafkaLZ4BlockInputStream(org.apache.kafka.common.compress.KafkaLZ4BlockInputStream) KafkaLZ4BlockOutputStream(org.apache.kafka.common.compress.KafkaLZ4BlockOutputStream) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.jupiter.api.Test)

Aggregations

ByteBuffer (java.nio.ByteBuffer)2 KafkaLZ4BlockInputStream (org.apache.kafka.common.compress.KafkaLZ4BlockInputStream)2 KafkaLZ4BlockOutputStream (org.apache.kafka.common.compress.KafkaLZ4BlockOutputStream)2 ByteBufferOutputStream (org.apache.kafka.common.utils.ByteBufferOutputStream)2 Test (org.junit.jupiter.api.Test)2