You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2024/03/29 10:58:48 UTC

(iotdb) branch master updated: Fix the mistaken argument in LZ4Uncompressor

This is an automated email from the ASF dual-hosted git repository.

jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new d8ac76ebe8c Fix the mistaken argument in LZ4Uncompressor
d8ac76ebe8c is described below

commit d8ac76ebe8c0b92a75a27eee17a8c627d73e0982
Author: Jiang Tian <jt...@163.com>
AuthorDate: Fri Mar 29 18:58:43 2024 +0800

    Fix the mistaken argument in LZ4Uncompressor
---
 .../apache/iotdb/tsfile/compress/IUnCompressor.java |  2 +-
 .../org/apache/iotdb/tsfile/compress/LZ4Test.java   | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/IUnCompressor.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/IUnCompressor.java
index f4302227f92..f2d40dc0d7a 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/IUnCompressor.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/IUnCompressor.java
@@ -238,7 +238,7 @@ public interface IUnCompressor {
     public int uncompress(byte[] byteArray, int offset, int length, byte[] output, int outOffset)
         throws IOException {
       try {
-        return decompressor.decompress(byteArray, offset, length, output, offset);
+        return decompressor.decompress(byteArray, offset, length, output, outOffset);
       } catch (RuntimeException e) {
         logger.error(UNCOMPRESS_INPUT_ERROR, e);
         throw new IOException(e);
diff --git a/iotdb-core/tsfile/src/test/java/org/apache/iotdb/tsfile/compress/LZ4Test.java b/iotdb-core/tsfile/src/test/java/org/apache/iotdb/tsfile/compress/LZ4Test.java
index 8e3aea195d2..42bee4f846e 100644
--- a/iotdb-core/tsfile/src/test/java/org/apache/iotdb/tsfile/compress/LZ4Test.java
+++ b/iotdb-core/tsfile/src/test/java/org/apache/iotdb/tsfile/compress/LZ4Test.java
@@ -80,4 +80,25 @@ public class LZ4Test {
     byte[] uncompressed = unCompressor.uncompress(compressed);
     Assert.assertArrayEquals(uncom, uncompressed);
   }
+
+  @Test
+  public void testBytes3() throws IOException {
+    ICompressor.IOTDBLZ4Compressor compressor = new ICompressor.IOTDBLZ4Compressor();
+    IUnCompressor.LZ4UnCompressor unCompressor = new IUnCompressor.LZ4UnCompressor();
+
+    int n = 500000;
+    int offset = 100;
+    String input = randomString(n);
+    byte[] origin = input.getBytes(StandardCharsets.UTF_8);
+    byte[] compressed = new byte[origin.length * 2];
+    int compressedLength = compressor.compress(origin, 0, origin.length, compressed);
+    System.arraycopy(compressed, 0, compressed, offset, compressedLength);
+    for (int i = 0; i < offset; i++) {
+      compressed[i] = 0;
+    }
+
+    byte[] uncompressed = new byte[origin.length];
+    unCompressor.uncompress(compressed, offset, compressedLength, uncompressed, 0);
+    Assert.assertArrayEquals(origin, uncompressed);
+  }
 }