mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
Add a java api for rocksdb::Options, currently only supports create_if_missing.
Summary: * [java] Add a java api for rocksdb::Options, currently only supports create_if_missing. * [java] Add a test for RocksDBException in RocksDBSample. Test Plan: make jtest Reviewers: haobo, sdong Reviewed By: haobo CC: leveldb, dhruba Differential Revision: https://reviews.facebook.net/D17385
This commit is contained in:
@@ -20,12 +20,16 @@ public class RocksDB {
|
||||
public static final int NOT_FOUND = -1;
|
||||
/**
|
||||
* The factory constructor of RocksDB that opens a RocksDB instance given
|
||||
* the path to the database.
|
||||
* the path to the database using the default options w/ createIfMissing
|
||||
* set to true.
|
||||
*
|
||||
* @param path the path to the rocksdb.
|
||||
* @param status an out value indicating the status of the Open().
|
||||
* @return a rocksdb instance on success, null if the specified rocksdb can
|
||||
* not be opened.
|
||||
*
|
||||
* @see Options.setCreateIfMissing()
|
||||
* @see Options.createIfMissing()
|
||||
*/
|
||||
public static RocksDB open(String path) throws RocksDBException {
|
||||
RocksDB db = new RocksDB();
|
||||
@@ -33,6 +37,17 @@ public class RocksDB {
|
||||
return db;
|
||||
}
|
||||
|
||||
/**
|
||||
* The factory constructor of RocksDB that opens a RocksDB instance given
|
||||
* the path to the database using the specified options and db path.
|
||||
*/
|
||||
public static RocksDB open(Options options, String path)
|
||||
throws RocksDBException {
|
||||
RocksDB db = new RocksDB();
|
||||
db.open(options.nativeHandle_, path);
|
||||
return db;
|
||||
}
|
||||
|
||||
public synchronized void close() {
|
||||
if (nativeHandle_ != 0) {
|
||||
close0();
|
||||
@@ -93,6 +108,7 @@ public class RocksDB {
|
||||
|
||||
// native methods
|
||||
private native void open0(String path) throws RocksDBException;
|
||||
private native void open(long optionsHandle, String path) throws RocksDBException;
|
||||
private native void put(
|
||||
byte[] key, int keyLen,
|
||||
byte[] value, int valueLen) throws RocksDBException;
|
||||
|
||||
Reference in New Issue
Block a user