-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for
com.github.luben:zstd-jni:1.5.2-5
- Loading branch information
1 parent
e0ab4f6
commit e138b4f
Showing
15 changed files
with
388 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[ | ||
"jni-config.json", | ||
"reflect-config.json", | ||
"resource-config.json" | ||
] |
114 changes: 114 additions & 0 deletions
114
metadata/com.github.luben/zstd-jni/1.5.2-5/jni-config.json
This file contains 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 |
---|---|---|
@@ -0,0 +1,114 @@ | ||
[ | ||
{ | ||
"condition": { | ||
"typeReachable": "com.github.luben.zstd.ZstdCompressCtx" | ||
}, | ||
"name": "com.github.luben.zstd.ZstdCompressCtx", | ||
"fields": [ | ||
{ | ||
"name": "nativePtr" | ||
} | ||
] | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "com.github.luben.zstd.ZstdDecompressCtx" | ||
}, | ||
"name": "com.github.luben.zstd.ZstdDecompressCtx", | ||
"fields": [ | ||
{ | ||
"name": "nativePtr" | ||
} | ||
] | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "com.github.luben.zstd.ZstdDictCompress" | ||
}, | ||
"name": "com.github.luben.zstd.ZstdDictCompress", | ||
"fields": [ | ||
{ | ||
"name": "nativePtr" | ||
} | ||
] | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "com.github.luben.zstd.ZstdDictDecompress" | ||
}, | ||
"name": "com.github.luben.zstd.ZstdDictDecompress", | ||
"fields": [ | ||
{ | ||
"name": "nativePtr" | ||
} | ||
] | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "com.github.luben.zstd.ZstdDirectBufferCompressingStreamNoFinalizer" | ||
}, | ||
"name": "com.github.luben.zstd.ZstdDirectBufferCompressingStream$1" | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "com.github.luben.zstd.ZstdDirectBufferCompressingStreamNoFinalizer" | ||
}, | ||
"name": "com.github.luben.zstd.ZstdDirectBufferCompressingStreamNoFinalizer", | ||
"fields": [ | ||
{ | ||
"name": "consumed" | ||
}, | ||
{ | ||
"name": "produced" | ||
} | ||
] | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "com.github.luben.zstd.ZstdDirectBufferDecompressingStreamNoFinalizer" | ||
}, | ||
"name": "com.github.luben.zstd.ZstdDirectBufferDecompressingStream$1" | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "com.github.luben.zstd.ZstdDirectBufferDecompressingStreamNoFinalizer" | ||
}, | ||
"name": "com.github.luben.zstd.ZstdDirectBufferDecompressingStreamNoFinalizer", | ||
"fields": [ | ||
{ | ||
"name": "consumed" | ||
}, | ||
{ | ||
"name": "produced" | ||
} | ||
] | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "com.github.luben.zstd.ZstdInputStreamNoFinalizer" | ||
}, | ||
"name": "com.github.luben.zstd.ZstdInputStreamNoFinalizer", | ||
"fields": [ | ||
{ | ||
"name": "dstPos" | ||
}, | ||
{ | ||
"name": "srcPos" | ||
} | ||
] | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "com.github.luben.zstd.ZstdOutputStreamNoFinalizer" | ||
}, | ||
"name": "com.github.luben.zstd.ZstdOutputStreamNoFinalizer", | ||
"fields": [ | ||
{ | ||
"name": "dstPos" | ||
}, | ||
{ | ||
"name": "srcPos" | ||
} | ||
] | ||
} | ||
] |
38 changes: 38 additions & 0 deletions
38
metadata/com.github.luben/zstd-jni/1.5.2-5/reflect-config.json
This file contains 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[ | ||
{ | ||
"condition": { | ||
"typeReachable": "com.github.luben.zstd.util.Native" | ||
}, | ||
"name": "java.security.SecureRandomParameters" | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "com.github.luben.zstd.util.Native" | ||
}, | ||
"name": "org.osgi.framework.BundleEvent" | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "com.github.luben.zstd.util.Native" | ||
}, | ||
"name": "sun.security.provider.NativePRNG", | ||
"methods": [ | ||
{ | ||
"name": "<init>", | ||
"parameterTypes": [] | ||
} | ||
] | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "com.github.luben.zstd.util.Native" | ||
}, | ||
"name": "sun.security.provider.SHA", | ||
"methods": [ | ||
{ | ||
"name": "<init>", | ||
"parameterTypes": [] | ||
} | ||
] | ||
} | ||
] |
13 changes: 13 additions & 0 deletions
13
metadata/com.github.luben/zstd-jni/1.5.2-5/resource-config.json
This file contains 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"bundles": [], | ||
"resources": { | ||
"includes": [ | ||
{ | ||
"condition": { | ||
"typeReachable": "com.github.luben.zstd.util.Native" | ||
}, | ||
"pattern": "[a-z]+/[a-z0-9]+/libzstd-jni-[0-9.-]+(so|dll|dylyb)" | ||
} | ||
] | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[ | ||
{ | ||
"latest": true, | ||
"metadata-version": "1.5.2-5", | ||
"module": "com.github.luben:zstd-jni", | ||
"tested-versions": [ | ||
"1.5.2-5" | ||
] | ||
} | ||
] |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
gradlew.bat | ||
gradlew | ||
gradle/ | ||
build/ |
This file contains 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
|
||
plugins { | ||
id "org.graalvm.internal.tck" | ||
} | ||
|
||
String libraryVersion = tck.testedLibraryVersion.get() | ||
|
||
dependencies { | ||
testImplementation "com.github.luben:zstd-jni:$libraryVersion" | ||
testImplementation 'org.assertj:assertj-core:3.22.0' | ||
} | ||
|
||
graalvmNative { | ||
agent { | ||
defaultMode = "conditional" | ||
modes { | ||
conditional { | ||
userCodeFilterPath = "user-code-filter.json" | ||
} | ||
} | ||
metadataCopy { | ||
mergeWithExisting = true | ||
inputTaskNames.add("test") | ||
outputDirectories.add("src/test/resources/META-INF/native-image/com.github.luben/zstd-jni") | ||
} | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
tests/src/com.github.luben/zstd-jni/1.5.2-5/gradle.properties
This file contains 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
library.version = 1.5.2-5 | ||
metadata.dir = com.github.luben/zstd-jni/1.5.2-5/ |
13 changes: 13 additions & 0 deletions
13
tests/src/com.github.luben/zstd-jni/1.5.2-5/settings.gradle
This file contains 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
pluginManagement { | ||
def tckPath = Objects.requireNonNullElse( | ||
System.getenv("GVM_TCK_TCKDIR"), | ||
"../../../../tck-build-logic" | ||
) | ||
includeBuild(tckPath) | ||
} | ||
|
||
plugins { | ||
id "org.graalvm.internal.tck-settings" version "1.0.0-SNAPSHOT" | ||
} | ||
|
||
rootProject.name = 'com.github.luben.zstd-jni_tests' |
130 changes: 130 additions & 0 deletions
130
...m.github.luben/zstd-jni/1.5.2-5/src/test/java/com_github_luben/zstd_jni/Zstd_jniTest.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
package com_github_luben.zstd_jni; | ||
|
||
import com.github.luben.zstd.Zstd; | ||
import com.github.luben.zstd.ZstdDictCompress; | ||
import com.github.luben.zstd.ZstdDictDecompress; | ||
import com.github.luben.zstd.ZstdDirectBufferCompressingStream; | ||
import com.github.luben.zstd.ZstdDirectBufferDecompressingStream; | ||
import com.github.luben.zstd.ZstdInputStream; | ||
import com.github.luben.zstd.ZstdOutputStream; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.io.RandomAccessFile; | ||
import java.nio.ByteBuffer; | ||
import java.nio.channels.FileChannel; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.Arrays; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
|
||
class Zstd_jniTest { | ||
@Test | ||
void testCompressAndDecompress() throws IOException { | ||
Path path = Paths.get("src/test/resources/originTest.txt"); | ||
byte[] bytes = new String(Files.readAllBytes(path)).getBytes(StandardCharsets.UTF_8); | ||
assertThat(bytes.length).isEqualTo(26); | ||
byte[] dictBytes = new String(Files.readAllBytes(path)).getBytes(StandardCharsets.UTF_8); | ||
ZstdDictCompress compressDict = new ZstdDictCompress(dictBytes, 10); | ||
ZstdDictDecompress decompressDict = new ZstdDictDecompress(dictBytes); | ||
byte[] compressed = Zstd.compress(bytes, compressDict); | ||
assertThat(compressed.length).isEqualTo(15); | ||
byte[] decompressed = Zstd.decompress(compressed, decompressDict, 1000000); | ||
assertThat(decompressed.length).isEqualTo(26); | ||
} | ||
|
||
@Test | ||
void testCompressFile() throws IOException { | ||
File file = new File("src/test/resources/originTest.txt"); | ||
File outFile = new File("src/test/resources/originTest.txt.zs"); | ||
long numBytes = 0L; | ||
ByteBuffer inBuffer = ByteBuffer.allocateDirect(8 * 1024 * 1024); | ||
ByteBuffer compressedBuffer = ByteBuffer.allocateDirect(8 * 1024 * 1024); | ||
try (RandomAccessFile inRaFile = new RandomAccessFile(file, "r"); | ||
RandomAccessFile outRaFile = new RandomAccessFile(outFile, "rw"); | ||
FileChannel inChannel = inRaFile.getChannel(); | ||
FileChannel outChannel = outRaFile.getChannel()) { | ||
inBuffer.clear(); | ||
while (inChannel.read(inBuffer) > 0) { | ||
inBuffer.flip(); | ||
compressedBuffer.clear(); | ||
long compressedSize = Zstd.compressDirectByteBuffer(compressedBuffer, 0, compressedBuffer.capacity(), inBuffer, 0, inBuffer.limit(), 10); | ||
numBytes = numBytes + compressedSize; | ||
compressedBuffer.position((int) compressedSize); | ||
compressedBuffer.flip(); | ||
outChannel.write(compressedBuffer); | ||
inBuffer.clear(); | ||
} | ||
} | ||
assertThat(numBytes).isEqualTo(35); | ||
assertDoesNotThrow(outFile::delete); | ||
} | ||
|
||
@Test | ||
void testDecompressFileByZstdIOStream() { | ||
File file = new File("src/test/resources/compressTest.zs"); | ||
File out = new File("src/test/resources/DecompressTest.txt"); | ||
byte[] buffer = new byte[1024 * 1024 * 8]; | ||
try (FileOutputStream fo = new FileOutputStream(out); | ||
ZstdOutputStream zos = new ZstdOutputStream(fo); | ||
FileInputStream fi = new FileInputStream(file.getPath()); | ||
ZstdInputStream zis = new ZstdInputStream(fi)) { | ||
while (true) { | ||
int count = zis.read(buffer, 0, buffer.length); | ||
if (count == -1) { | ||
break; | ||
} | ||
zos.write(buffer, 0, count); | ||
} | ||
zos.flush(); | ||
} catch (IOException ignore) { | ||
} | ||
assertDoesNotThrow(out::delete); | ||
} | ||
|
||
@Test | ||
void testDirectBufferDecompressingStream() throws IOException { | ||
byte[] input = Files.readAllBytes(Paths.get("src/test/resources/originTest.txt")); | ||
final int size = input.length; | ||
ByteBuffer os = ByteBuffer.allocateDirect((int) Zstd.compressBound(size)); | ||
final ByteBuffer ib = ByteBuffer.allocateDirect(size); | ||
ib.put(input); | ||
final ZstdDirectBufferCompressingStream osw = new ZstdDirectBufferCompressingStream(os, 9); | ||
ib.flip(); | ||
osw.compress(ib); | ||
osw.close(); | ||
os.flip(); | ||
final byte[] bytes = new byte[os.limit()]; | ||
os.get(bytes); | ||
os.rewind(); | ||
final ZstdDirectBufferDecompressingStream zis = new ZstdDirectBufferDecompressingStream(os); | ||
final byte[] output = new byte[size]; | ||
final ByteBuffer block = ByteBuffer.allocateDirect(128 * 1024); | ||
int offset = 0; | ||
while (zis.hasRemaining()) { | ||
block.clear(); | ||
final int read = zis.read(block); | ||
block.flip(); | ||
block.get(output, offset, read); | ||
offset = offset + read; | ||
} | ||
zis.close(); | ||
String s = "[97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122]"; | ||
assertThat(Arrays.toString(input)).isEqualTo(s); | ||
assertThat(Arrays.toString(output)).isEqualTo(s); | ||
} | ||
|
||
} |
Binary file added
BIN
+35 Bytes
tests/src/com.github.luben/zstd-jni/1.5.2-5/src/test/resources/compressTest.zs
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/src/com.github.luben/zstd-jni/1.5.2-5/src/test/resources/originTest.txt
This file contains 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
abcdefghijklmnopqrstuvwxyz |
Oops, something went wrong.