MCPcopy Create free account
hub / github.com/bytedance/terarkdb / loadLibrary

Method loadLibrary

java/src/main/java/org/rocksdb/RocksDB.java:45–82  ·  view source on GitHub ↗

Loads the necessary library files. Calling this method twice will have no effect. By default the method extracts the shared library for loading at java.io.tmpdir, however, you can override this temporary location by setting the environment variable ROCKSDB_SHAREDLIB_DIR.

()

Source from the content-addressed store, hash-verified

43 * setting the environment variable ROCKSDB_SHAREDLIB_DIR.
44 */
45 public static void loadLibrary() {
46 if (libraryLoaded.get() == LibraryState.LOADED) {
47 return;
48 }
49
50 if (libraryLoaded.compareAndSet(LibraryState.NOT_LOADED,
51 LibraryState.LOADING)) {
52 final String tmpDir = System.getenv("ROCKSDB_SHAREDLIB_DIR");
53 // loading possibly necessary libraries.
54 for (final CompressionType compressionType : CompressionType.values()) {
55 try {
56 if (compressionType.getLibraryName() != null) {
57 System.loadLibrary(compressionType.getLibraryName());
58 }
59 } catch (UnsatisfiedLinkError e) {
60 // since it may be optional, we ignore its loading failure here.
61 }
62 }
63 try {
64 NativeLibraryLoader.getInstance().loadLibrary(tmpDir);
65 } catch (IOException e) {
66 libraryLoaded.set(LibraryState.NOT_LOADED);
67 throw new RuntimeException("Unable to load the RocksDB shared library"
68 + e);
69 }
70
71 libraryLoaded.set(LibraryState.LOADED);
72 return;
73 }
74
75 while (libraryLoaded.get() == LibraryState.LOADING) {
76 try {
77 Thread.sleep(10);
78 } catch(final InterruptedException e) {
79 //ignore
80 }
81 }
82 }
83
84 /**
85 * Tries to load the necessary library files from the given list of

Callers 15

mainMethod · 0.95
RocksDBSampleClass · 0.95
DbBenchmarkClass · 0.95
RocksMemoryResourceClass · 0.95
setUpMethod · 0.95
ClockCacheTestClass · 0.95
LRUCacheTestClass · 0.95

Calls 7

getInstanceMethod · 0.95
getJniLibraryFileNameMethod · 0.95
getLibraryNameMethod · 0.80
getMethod · 0.45
setMethod · 0.45
equalsMethod · 0.45

Tested by 1

setUpMethod · 0.76