Skip to content

Commit be53471

Browse files
authored
Remove unneccessary ArrayUtil.grow in Zstd compression modes. (#121)
Signed-off-by: Mulugeta Mammo <mulugeta.mammo@intel.com>
1 parent 6eb028f commit be53471

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

src/main/java/org/opensearch/index/codec/customcodecs/ZstdCompressionMode.java

-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ public void decompress(DataInput in, int originalLength, int offset, int length,
188188

189189
// Read blocks that intersect with the interval we need
190190
while (offsetInBlock < offset + length) {
191-
bytes.bytes = ArrayUtil.grow(bytes.bytes, bytes.length + blockLength);
192191
int l = Math.min(blockLength, originalLength - offsetInBlock);
193192
doDecompress(in, dctx, bytes, l);
194193
offsetInBlock += blockLength;

src/main/java/org/opensearch/index/codec/customcodecs/ZstdNoDictCompressionMode.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ public void decompress(DataInput in, int originalLength, int offset, int length,
148148

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

162-
byte[] output = new byte[l];
163-
164-
final int uncompressed = (int) Zstd.decompressByteArray(output, 0, l, compressed, 0, compressedLength);
165-
System.arraycopy(output, 0, bytes.bytes, bytes.length, uncompressed);
161+
final int uncompressed = (int) Zstd.decompressByteArray(bytes.bytes, bytes.length, l, compressed, 0, compressedLength);
166162

167163
bytes.length += uncompressed;
168164
offsetInBlock += blockLength;

0 commit comments

Comments
 (0)