Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import io.druid.java.util.common.logger.Logger;
import io.druid.segment.CompressedPools;
import net.jpountz.lz4.LZ4Factory;
import net.jpountz.lz4.LZ4FastDecompressor;
import net.jpountz.lz4.LZ4SafeDecompressor;
import org.apache.commons.lang.ArrayUtils;

Expand Down Expand Up @@ -264,7 +263,6 @@ public byte[] compress(byte[] bytes)
public static class LZ4Decompressor implements Decompressor
{
private static final LZ4SafeDecompressor lz4Safe = LZ4Factory.fastestInstance().safeDecompressor();
private static final LZ4FastDecompressor lz4Fast = LZ4Factory.fastestInstance().fastDecompressor();
private static final LZ4Decompressor defaultDecompressor = new LZ4Decompressor();

@Override
Expand All @@ -286,8 +284,17 @@ public void decompress(ByteBuffer in, int numBytes, ByteBuffer out)
@Override
public void decompress(ByteBuffer in, int numBytes, ByteBuffer out, int decompressedSize)
{
// lz4Fast.decompress does not modify buffer positions
lz4Fast.decompress(in, in.position(), out, out.position(), decompressedSize);
// lz4Safe.decompress does not modify buffer positions.
// Using lz4Safe API for forward-compatibility with https://github.com/druid-io/druid/pull/4762, which doesn't
// always compressed blocks of the same size.
lz4Safe.decompress(
in,
in.position(),
numBytes,
out,
out.position(),
decompressedSize
);
out.limit(out.position() + decompressedSize);
}
}
Expand Down