From cd30687a15da992d0070980132d3d50d1af0aff1 Mon Sep 17 00:00:00 2001 From: Akira Ajisaka Date: Tue, 28 Dec 2021 21:51:40 +0900 Subject: [PATCH] Revert "HDFS-14099. Unknown frame descriptor when decompressing multiple frames (#3836)" This reverts commit 05b43f205758a39ac5af25a9c7b699704e3b99d2. --- .../compress/zstd/ZStandardDecompressor.java | 13 ---- .../TestZStandardCompressorDecompressor.java | 59 ------------------- 2 files changed, 72 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zstd/ZStandardDecompressor.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zstd/ZStandardDecompressor.java index adf2fe629f..bc9d29cb4f 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zstd/ZStandardDecompressor.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zstd/ZStandardDecompressor.java @@ -113,12 +113,6 @@ private void setInputFromSavedData() { compressedDirectBuf.put( userBuf, userBufOff, bytesInCompressedBuffer); - // Set the finished to false when compressedDirectBuf still - // contains some bytes. - if (compressedDirectBuf.position() > 0 && finished) { - finished = false; - } - userBufOff += bytesInCompressedBuffer; userBufferBytesToConsume -= bytesInCompressedBuffer; } @@ -192,13 +186,6 @@ public int decompress(byte[] b, int off, int len) 0, directBufferSize ); - - // Set the finished to false when compressedDirectBuf still - // contains some bytes. - if (remaining > 0 && finished) { - finished = false; - } - uncompressedDirectBuf.limit(n); // Get at most 'len' bytes diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/zstd/TestZStandardCompressorDecompressor.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/zstd/TestZStandardCompressorDecompressor.java index 653225b708..dcfb7e9e32 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/zstd/TestZStandardCompressorDecompressor.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/zstd/TestZStandardCompressorDecompressor.java @@ -234,65 +234,6 @@ public void testCompressorDecompressorLogicWithCompressionStreams() } } - /** - * Verify decompressor logic with some finish operation in compress. - */ - @Test - public void testCompressorDecompressorWithFinish() throws Exception { - DataOutputStream deflateOut = null; - DataInputStream inflateIn = null; - int byteSize = 1024 * 100; - byte[] bytes = generate(byteSize); - int firstLength = 1024 * 30; - - int bufferSize = IO_FILE_BUFFER_SIZE_DEFAULT; - try { - DataOutputBuffer compressedDataBuffer = new DataOutputBuffer(); - CompressionOutputStream deflateFilter = - new CompressorStream(compressedDataBuffer, new ZStandardCompressor(), - bufferSize); - - deflateOut = - new DataOutputStream(new BufferedOutputStream(deflateFilter)); - - // Write some data and finish. - deflateOut.write(bytes, 0, firstLength); - deflateFilter.finish(); - deflateOut.flush(); - - // ResetState then write some data and finish. - deflateFilter.resetState(); - deflateOut.write(bytes, firstLength, firstLength); - deflateFilter.finish(); - deflateOut.flush(); - - // ResetState then write some data and finish. - deflateFilter.resetState(); - deflateOut.write(bytes, firstLength * 2, byteSize - firstLength * 2); - deflateFilter.finish(); - deflateOut.flush(); - - DataInputBuffer deCompressedDataBuffer = new DataInputBuffer(); - deCompressedDataBuffer.reset(compressedDataBuffer.getData(), 0, - compressedDataBuffer.getLength()); - - CompressionInputStream inflateFilter = - new DecompressorStream(deCompressedDataBuffer, - new ZStandardDecompressor(bufferSize), bufferSize); - - inflateIn = new DataInputStream(new BufferedInputStream(inflateFilter)); - - byte[] result = new byte[byteSize]; - inflateIn.read(result); - assertArrayEquals( - "original array not equals compress/decompressed array", bytes, - result); - } finally { - IOUtils.closeStream(deflateOut); - IOUtils.closeStream(inflateIn); - } - } - @Test public void testZStandardCompressDecompressInMultiThreads() throws Exception { MultithreadedTestUtil.TestContext ctx =