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

Method main

java/RocksDBJava.java:6–30  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

4
5public class RocksDBJava {
6 public static void main(String[] args){
7 RocksDB.loadLibrary();
8 System.out.println("Hello RocksDB!");
9
10 // the Options class contains a set of configurable DB options
11 // that determines the behaviour of the database.
12 try (final Options options = new Options().setCreateIfMissing(true)) {
13 // a factory method that returns a RocksDB instance
14 try (final RocksDB db = RocksDB.open(options, "/tmp/")) {
15 byte[] key1 = "key1".getBytes();
16 byte[] key2 = "key2".getBytes();
17
18 final byte[] value = db.get(key1);
19 if (value == null) {
20 db.put(key2, "correct value".getBytes());
21 final byte[] v = db.get(key2);
22 System.out.println(new String(v));
23 }
24
25 // do something
26 }
27 } catch (RocksDBException e) {
28 e.printStackTrace();
29 }
30 }
31}

Callers 4

ldb_test.pyFile · 0.45

Calls 5

loadLibraryMethod · 0.95
openMethod · 0.95
setCreateIfMissingMethod · 0.65
putMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected