(String[] args)
| 4 | |
| 5 | public 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 | } |
no test coverage detected