xinglin commented on code in PR #4208:
URL: https://github.com/apache/hadoop/pull/4208#discussion_r854824985
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/snappy/TestSnappyCompressorDecompressor.java:
##########
@@ -278,7 +285,38 @@ public void testSnappyBlockCompression() {
fail("testSnappyBlockCompression ex error !!!");
}
}
-
+
+ @Test
+ // The buffer size is smaller than the input.
+ public void testSnappyCompressDecompressWithSmallBuffer() throws Exception {
+ int inputSize = 1024 * 50;
+ int bufferSize = 512;
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ byte[] buffer = new byte[bufferSize];
+ byte[] input = BytesGenerator.get(inputSize);
+
+ SnappyCompressor compressor = new SnappyCompressor();
+ compressor.setInput(input, 0, inputSize);
+ compressor.finish();
+ while (!compressor.finished()) {
+ int len = compressor.compress(buffer, 0, buffer.length);
+ out.write(buffer, 0, len);
+ }
+ byte[] compressed = out.toByteArray();
+ assertTrue(compressed.length > 0);
+ out.reset();
+
+ SnappyDecompressor decompressor = new SnappyDecompressor();
+ decompressor.setInput(compressed, 0, compressed.length);
+ while (!decompressor.finished()) {
+ int len = decompressor.decompress(buffer, 0, buffer.length);
+ out.write(buffer, 0, len);
+ }
+ byte[] decompressed = out.toByteArray();
+
+ assertTrue(Arrays.equals(decompressed, input));
Review Comment:
ack. Thanks for the suggestion.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]