Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,13 @@ public int read() throws IOException {
public void resetState() throws IOException {
// no-opt, doesn't apply to ZSTD
}

@Override
public void close() throws IOException {
try {
zstdInputStream.close();
} finally {
super.close();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ private void testZstd(ZstandardCodec codec, int dataSize) throws IOException {
byte[] data = new byte[dataSize];
(new Random()).nextBytes(data);
BytesInput compressedData = compress(codec, BytesInput.from(data));
BytesInput decompressedData = decompress(codec, compressedData, data.length);
Assert.assertArrayEquals(data, decompressedData.toByteArray());
byte[] decompressedData = decompress(codec, compressedData, data.length);
Assert.assertArrayEquals(data, decompressedData);
}

private BytesInput compress(ZstandardCodec codec, BytesInput bytes) throws IOException {
Expand All @@ -91,10 +91,9 @@ private BytesInput compress(ZstandardCodec codec, BytesInput bytes) throws IOExc
return BytesInput.from(compressedOutBuffer);
}

private BytesInput decompress(ZstandardCodec codec, BytesInput bytes, int uncompressedSize) throws IOException {
BytesInput decompressed;
private byte[] decompress(ZstandardCodec codec, BytesInput bytes, int uncompressedSize) throws IOException {
InputStream is = codec.createInputStream(bytes.toInputStream(), null);
decompressed = BytesInput.from(is, uncompressedSize);
byte[] decompressed = BytesInput.from(is, uncompressedSize).toByteArray();
is.close();
return decompressed;
}
Expand Down