dbtsai commented on a change in pull request #2297:
URL: https://github.com/apache/hadoop/pull/2297#discussion_r494537597
##########
File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/snappy/SnappyCompressor.java
##########
@@ -291,9 +283,17 @@ public long getBytesWritten() {
public void end() {
}
- private native static void initIDs();
-
- private native int compressBytesDirect();
-
- public native static String getLibraryName();
+ private int compressDirectBuf() throws IOException {
+ if (uncompressedDirectBufLen == 0) {
+ return 0;
+ } else {
+ // Set the position and limit of `uncompressedDirectBuf` for reading
+ uncompressedDirectBuf.limit(uncompressedDirectBufLen).position(0);
+ int size = Snappy.compress((ByteBuffer) uncompressedDirectBuf,
+ (ByteBuffer) compressedDirectBuf);
+ uncompressedDirectBufLen = 0;
+ uncompressedDirectBuf.limit(directBufferSize).position(0);
Review comment:
nit, `uncompressedDirectBuf.limit(uncompressedDirectBuf.capacity()).position(0);` for
safety.
##########
File path: hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/CompressDecompressTester.java
##########
@@ -432,7 +412,11 @@ public void assertCompression(String name, Compressor compressor,
joiner.join(name, "byte arrays not equals error !!!"),
originalRawData, decompressOut.toByteArray());
} catch (Exception ex) {
- fail(joiner.join(name, ex.getMessage()));
+ if (ex.getMessage() != null) {
+ fail(joiner.join(name, ex.getMessage()));
+ } else {
+ fail(joiner.join(name, ExceptionUtils.getStackTrace(ex)));
Review comment:
Why is this change needed?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
|