Load zstd before rocksdb

This commit is contained in:
Andrea Cavalli 2024-09-27 00:18:13 +02:00
parent 1621bb73ca
commit b2bfd0f23a

View File

@ -43,18 +43,6 @@ public class RocksDBLoader {
private static final String bugFallbackJniLibraryFileName = Environment.getFallbackJniLibraryFileName("rocksdbjni"); private static final String bugFallbackJniLibraryFileName = Environment.getFallbackJniLibraryFileName("rocksdbjni");
public static void loadLibrary() { public static void loadLibrary() {
try {
String currentUsersHomeDir = System.getProperty("user.home");
var jniPath = Path.of(currentUsersHomeDir).resolve(".jni").resolve("rocksdb").resolve(RocksDBMetadata.getRocksDBVersionHash());
if (Files.notExists(jniPath)) {
Files.createDirectories(jniPath);
}
loadLibraryFromJarToTemp(jniPath);
RocksDB.loadLibrary(List.of(jniPath.toAbsolutePath().toString()));
} catch (IOException e) {
RocksDB.loadLibrary();
}
for (final CompressionType compressionType : CompressionType.values()) { for (final CompressionType compressionType : CompressionType.values()) {
try { try {
if (compressionType.getLibraryName() != null) { if (compressionType.getLibraryName() != null) {
@ -67,6 +55,18 @@ public class RocksDBLoader {
// since it may be optional, we ignore its loading failure here. // since it may be optional, we ignore its loading failure here.
} }
} }
try {
String currentUsersHomeDir = System.getProperty("user.home");
var jniPath = Path.of(currentUsersHomeDir).resolve(".jni").resolve("rocksdb").resolve(RocksDBMetadata.getRocksDBVersionHash());
if (Files.notExists(jniPath)) {
Files.createDirectories(jniPath);
}
loadLibraryFromJarToTemp(jniPath);
RocksDB.loadLibrary(List.of(jniPath.toAbsolutePath().toString()));
} catch (IOException e) {
RocksDB.loadLibrary();
}
} }
private static Path loadLibraryFromJarToTemp(final Path tmpDir) throws IOException { private static Path loadLibraryFromJarToTemp(final Path tmpDir) throws IOException {