You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by li...@apache.org on 2023/12/21 13:32:44 UTC
(arrow) branch main updated: GH-38725: [Java] decompression in Lz4CompressionCodec.java does not set writer index (#38840)
This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 596259ee47 GH-38725: [Java] decompression in Lz4CompressionCodec.java does not set writer index (#38840)
596259ee47 is described below
commit 596259ee47b5c675b71432743d9bfd196efe08e3
Author: Vibhatha Lakmal Abeykoon <vi...@users.noreply.github.com>
AuthorDate: Thu Dec 21 19:02:38 2023 +0530
GH-38725: [Java] decompression in Lz4CompressionCodec.java does not set writer index (#38840)
### Rationale for this change
The `doDecompress` function in `Lz4CompressionCodec` misses writing the index when it is compared with the functionality in `ZstdCompressionCodec`. This PR fixes that issue.
### What changes are included in this PR?
Writes the index for the decompressed ArrowBuf.
### Are these changes tested?
No
### Are there any user-facing changes?
No
* Closes: #38725
Lead-authored-by: Vibhatha Lakmal Abeykoon <vi...@gmail.com>
Co-authored-by: vibhatha <vi...@gmail.com>
Signed-off-by: David Li <li...@gmail.com>
---
.../java/org/apache/arrow/compression/Lz4CompressionCodec.java | 1 +
.../java/org/apache/arrow/compression/TestCompressionCodec.java | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/java/compression/src/main/java/org/apache/arrow/compression/Lz4CompressionCodec.java b/java/compression/src/main/java/org/apache/arrow/compression/Lz4CompressionCodec.java
index daa35b7e15..e8b780638e 100644
--- a/java/compression/src/main/java/org/apache/arrow/compression/Lz4CompressionCodec.java
+++ b/java/compression/src/main/java/org/apache/arrow/compression/Lz4CompressionCodec.java
@@ -79,6 +79,7 @@ public class Lz4CompressionCodec extends AbstractCompressionCodec {
byte[] outBytes = out.toByteArray();
ArrowBuf decompressedBuffer = allocator.buffer(outBytes.length);
decompressedBuffer.setBytes(/*index=*/0, outBytes);
+ decompressedBuffer.writerIndex(decompressedLength);
return decompressedBuffer;
}
diff --git a/java/compression/src/test/java/org/apache/arrow/compression/TestCompressionCodec.java b/java/compression/src/test/java/org/apache/arrow/compression/TestCompressionCodec.java
index 403130edba..01156fa2b0 100644
--- a/java/compression/src/test/java/org/apache/arrow/compression/TestCompressionCodec.java
+++ b/java/compression/src/test/java/org/apache/arrow/compression/TestCompressionCodec.java
@@ -117,6 +117,12 @@ class TestCompressionCodec {
return outputBuffers;
}
+ private void assertWriterIndex(List<ArrowBuf> decompressedBuffers) {
+ for (ArrowBuf decompressedBuf : decompressedBuffers) {
+ assertTrue(decompressedBuf.writerIndex() > 0);
+ }
+ }
+
@ParameterizedTest
@MethodSource("codecs")
void testCompressFixedWidthBuffers(int vectorLength, CompressionCodec codec) throws Exception {
@@ -139,6 +145,7 @@ class TestCompressionCodec {
List<ArrowBuf> decompressedBuffers = deCompressBuffers(codec, compressedBuffers);
assertEquals(2, decompressedBuffers.size());
+ assertWriterIndex(decompressedBuffers);
// orchestrate new vector
IntVector newVec = new IntVector("new vec", allocator);
@@ -180,6 +187,7 @@ class TestCompressionCodec {
List<ArrowBuf> decompressedBuffers = deCompressBuffers(codec, compressedBuffers);
assertEquals(3, decompressedBuffers.size());
+ assertWriterIndex(decompressedBuffers);
// orchestrate new vector
VarCharVector newVec = new VarCharVector("new vec", allocator);