Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Remove redundant array resizing in Zstd compression modes. #123

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
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 @@ -188,7 +188,6 @@ public void decompress(DataInput in, int originalLength, int offset, int length,

// Read blocks that intersect with the interval we need
while (offsetInBlock < offset + length) {
bytes.bytes = ArrayUtil.grow(bytes.bytes, bytes.length + blockLength);
int l = Math.min(blockLength, originalLength - offsetInBlock);
doDecompress(in, dctx, bytes, l);
offsetInBlock += blockLength;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ public void decompress(DataInput in, int originalLength, int offset, int length,

// Read blocks that intersect with the interval we need
while (offsetInBlock < offset + length) {
bytes.bytes = ArrayUtil.grow(bytes.bytes, bytes.length + blockLength);
final int compressedLength = in.readVInt();
if (compressedLength == 0) {
return;
Expand All @@ -159,10 +158,7 @@ public void decompress(DataInput in, int originalLength, int offset, int length,
int l = Math.min(blockLength, originalLength - offsetInBlock);
bytes.bytes = ArrayUtil.grow(bytes.bytes, bytes.length + l);

byte[] output = new byte[l];

final int uncompressed = (int) Zstd.decompressByteArray(output, 0, l, compressed, 0, compressedLength);
System.arraycopy(output, 0, bytes.bytes, bytes.length, uncompressed);
final int uncompressed = (int) Zstd.decompressByteArray(bytes.bytes, bytes.length, l, compressed, 0, compressedLength);

bytes.length += uncompressed;
offsetInBlock += blockLength;
Expand Down
Loading