-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-17125. Using snappy-java in SnappyCodec #2297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
23da513
SnappyCodec with java-snappy
dbtsai 3aa3f55
rebase master
dbtsai 65fd9f4
Reset compressedDirectBuf and uncompressedDirectBuf.
viirya 9c0f08b
Revert some debugging code.
viirya f52dd20
Remove snappy native code.
viirya 87903a9
Remove snappy compilation.
viirya 5adcf53
Fix limit parameter.
viirya 40cc18a
Remove require.snappy.
viirya 0e44d4b
trigger CI
viirya 666a37b
Add compatibility test.
viirya 9de4712
Check snappy library and remove useless code.
viirya 0ed518d
Revert trailing whitespace.
viirya 712749c
For review comment.
viirya 2b5a212
Address review comments.
viirya 1cb398b
Take safer approach.
viirya aa6a6d5
For review comments.
viirya 19edba2
Update BUILDING and NativeLibraries.
viirya beec931
Merge remote-tracking branch 'upstream/trunk' into java-snappy
viirya fc525fa
Make snappy-java as compile scope.
viirya 562b80d
For review comment.
viirya 0600169
Revert Snappy description in BUILDING.txt.
viirya fd71a20
Fix style issue.
viirya 7dc320d
Fix another style...
viirya 5685b0b
Address comments: throwing AssertionError and exclude jobTokenPasswor…
viirya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,9 +24,9 @@ | |
|
|
||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.io.compress.Compressor; | ||
| import org.apache.hadoop.util.NativeCodeLoader; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.xerial.snappy.Snappy; | ||
|
|
||
| /** | ||
| * A {@link Compressor} based on the snappy compression algorithm. | ||
|
|
@@ -48,24 +48,6 @@ public class SnappyCompressor implements Compressor { | |
| private long bytesRead = 0L; | ||
| private long bytesWritten = 0L; | ||
|
|
||
| private static boolean nativeSnappyLoaded = false; | ||
|
|
||
| static { | ||
| if (NativeCodeLoader.isNativeCodeLoaded() && | ||
| NativeCodeLoader.buildSupportsSnappy()) { | ||
| try { | ||
| initIDs(); | ||
| nativeSnappyLoaded = true; | ||
| } catch (Throwable t) { | ||
| LOG.error("failed to load SnappyCompressor", t); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public static boolean isNativeCodeLoaded() { | ||
| return nativeSnappyLoaded; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need to check if the snappy class is available for SnappyCompressor too.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added. |
||
| } | ||
|
|
||
| /** | ||
| * Creates a new compressor. | ||
| * | ||
|
|
@@ -225,7 +207,7 @@ public int compress(byte[] b, int off, int len) | |
| } | ||
|
|
||
| // Compress data | ||
| n = compressBytesDirect(); | ||
| n = compressDirectBuf(); | ||
| compressedDirectBuf.limit(n); | ||
| uncompressedDirectBuf.clear(); // snappy consumes all buffer input | ||
|
|
||
|
|
@@ -291,9 +273,16 @@ 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; | ||
| return size; | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.