diff --git a/pom.xml b/pom.xml index 928f0c5e8..ce766e3c6 100644 --- a/pom.xml +++ b/pom.xml @@ -39,7 +39,7 @@ 1.8 1.8 - + false @@ -202,7 +202,7 @@ org.apache.tsfile,,javax,java,\# - + UNIX @@ -301,7 +301,7 @@ validate - + diff --git a/tsfile/src/main/java/org/apache/tsfile/compress/IUnCompressor.java b/tsfile/src/main/java/org/apache/tsfile/compress/IUnCompressor.java index aabac3bfe..c3560bc24 100644 --- a/tsfile/src/main/java/org/apache/tsfile/compress/IUnCompressor.java +++ b/tsfile/src/main/java/org/apache/tsfile/compress/IUnCompressor.java @@ -238,7 +238,7 @@ public byte[] uncompress(byte[] bytes) throws IOException { 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/tsfile/src/test/java/org/apache/tsfile/compress/LZ4Test.java b/tsfile/src/test/java/org/apache/tsfile/compress/LZ4Test.java index 2b62f87fc..299c70f73 100644 --- a/tsfile/src/test/java/org/apache/tsfile/compress/LZ4Test.java +++ b/tsfile/src/test/java/org/apache/tsfile/compress/LZ4Test.java @@ -80,4 +80,25 @@ public void testBytes2() throws IOException { byte[] uncompressed = unCompressor.uncompress(compressed); Assert.assertArrayEquals(uncom, uncompressed); } + + @Test + public void testBytes3() throws IOException { + LZ4Compressor compressor = new LZ4Compressor(); + 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); + } }