Skip to content

Commit

Permalink
LZ4 Backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
laullon committed Sep 19, 2023
1 parent 36ec7e1 commit 8acdb11
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import java.util.zip.GZIPOutputStream;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import org.apache.commons.compress.compressors.lz4.BlockLZ4CompressorInputStream;
import org.apache.commons.compress.compressors.lz4.BlockLZ4CompressorOutputStream;
import org.apache.commons.compress.compressors.lz4.FramedLZ4CompressorInputStream;
import org.apache.commons.compress.compressors.lz4.FramedLZ4CompressorOutputStream;
import org.apache.commons.io.IOUtils;
Expand Down Expand Up @@ -72,7 +75,7 @@ public T fromBytes(@Nonnull byte[] bytes) {
try {
switch (compression) {
case FORMAT_LZ4:
stream = new FramedLZ4CompressorInputStream(input);
stream = new BlockLZ4CompressorInputStream(input);
break;
case FORMAT_GZIP:
stream = new GZIPInputStream(input);
Expand Down Expand Up @@ -116,8 +119,8 @@ public void serializeToStream(@Nonnull T t, @Nonnull OutputStream bytes) throws
case LZ4:
bytes.write(FORMAT_LZ4);
bytes.write(ByteBuffer.allocate(4).putInt(t.weight()).array());
FramedLZ4CompressorOutputStream lz4BlockOutputStream =
new FramedLZ4CompressorOutputStream(bytes);
BlockLZ4CompressorOutputStream lz4BlockOutputStream =
new BlockLZ4CompressorOutputStream(bytes);
objectMapper.writeValue(lz4BlockOutputStream, t);
lz4BlockOutputStream.close();
return;
Expand Down

0 comments on commit 8acdb11

Please sign in to comment.