[RocksJava] Integrated Review comments from yhchiang in D28023
This commit is contained in:
parent
75010d2084
commit
fa9cfc65f3
|
@ -130,14 +130,14 @@ public class RocksDB extends RocksObject {
|
||||||
* {@link RocksDB} can not be opened.
|
* {@link RocksDB} can not be opened.
|
||||||
*
|
*
|
||||||
* @throws org.rocksdb.RocksDBException
|
* @throws org.rocksdb.RocksDBException
|
||||||
* @see Options#setCreateIfMissing(boolean)
|
* @see DBOptions#setCreateIfMissing(boolean)
|
||||||
*/
|
*/
|
||||||
public static RocksDB open(String path,
|
public static RocksDB open(String path,
|
||||||
List<ColumnFamilyDescriptor> columnFamilyDescriptors,
|
List<ColumnFamilyDescriptor> columnFamilyDescriptors,
|
||||||
List<ColumnFamilyHandle> columnFamilyHandles) throws RocksDBException {
|
List<ColumnFamilyHandle> columnFamilyHandles) throws RocksDBException {
|
||||||
// This allows to use the rocksjni default Options instead of
|
// This allows to use the rocksjni default Options instead of
|
||||||
// the c++ one.
|
// the c++ one.
|
||||||
Options options = new Options();
|
DBOptions options = new DBOptions();
|
||||||
return open(options, path, columnFamilyDescriptors, columnFamilyHandles);
|
return open(options, path, columnFamilyDescriptors, columnFamilyHandles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ public class RocksDB extends RocksObject {
|
||||||
* <p>
|
* <p>
|
||||||
* ColumnFamily handles are disposed when the RocksDB instance is disposed.</p>
|
* ColumnFamily handles are disposed when the RocksDB instance is disposed.</p>
|
||||||
*
|
*
|
||||||
* @param options {@link org.rocksdb.Options} instance.
|
* @param options {@link org.rocksdb.DBOptions} instance.
|
||||||
* @param path the path to the rocksdb.
|
* @param path the path to the rocksdb.
|
||||||
* @param columnFamilyDescriptors list of column family descriptors
|
* @param columnFamilyDescriptors list of column family descriptors
|
||||||
* @param columnFamilyHandles will be filled with ColumnFamilyHandle instances
|
* @param columnFamilyHandles will be filled with ColumnFamilyHandle instances
|
||||||
|
@ -206,16 +206,16 @@ public class RocksDB extends RocksObject {
|
||||||
* {@link RocksDB} can not be opened.
|
* {@link RocksDB} can not be opened.
|
||||||
*
|
*
|
||||||
* @throws org.rocksdb.RocksDBException
|
* @throws org.rocksdb.RocksDBException
|
||||||
* @see Options#setCreateIfMissing(boolean)
|
* @see DBOptions#setCreateIfMissing(boolean)
|
||||||
*/
|
*/
|
||||||
public static RocksDB open(Options options, String path,
|
public static RocksDB open(DBOptions options, String path,
|
||||||
List<ColumnFamilyDescriptor> columnFamilyDescriptors,
|
List<ColumnFamilyDescriptor> columnFamilyDescriptors,
|
||||||
List<ColumnFamilyHandle> columnFamilyHandles)
|
List<ColumnFamilyHandle> columnFamilyHandles)
|
||||||
throws RocksDBException {
|
throws RocksDBException {
|
||||||
RocksDB db = new RocksDB();
|
RocksDB db = new RocksDB();
|
||||||
List<Long> cfReferences = db.open(options.nativeHandle_, path,
|
List<Long> cfReferences = db.open(options.nativeHandle_, path,
|
||||||
columnFamilyDescriptors, columnFamilyDescriptors.size());
|
columnFamilyDescriptors, columnFamilyDescriptors.size());
|
||||||
for (int i=0; i<columnFamilyDescriptors.size(); i++) {
|
for (int i = 0; i < columnFamilyDescriptors.size(); i++) {
|
||||||
columnFamilyHandles.add(new ColumnFamilyHandle(db, cfReferences.get(i)));
|
columnFamilyHandles.add(new ColumnFamilyHandle(db, cfReferences.get(i)));
|
||||||
}
|
}
|
||||||
db.storeOptionsInstance(options);
|
db.storeOptionsInstance(options);
|
||||||
|
@ -258,7 +258,7 @@ public class RocksDB extends RocksObject {
|
||||||
List<ColumnFamilyHandle> columnFamilyHandles) throws RocksDBException {
|
List<ColumnFamilyHandle> columnFamilyHandles) throws RocksDBException {
|
||||||
// This allows to use the rocksjni default Options instead of
|
// This allows to use the rocksjni default Options instead of
|
||||||
// the c++ one.
|
// the c++ one.
|
||||||
Options options = new Options();
|
DBOptions options = new DBOptions();
|
||||||
return openReadOnly(options, path, columnFamilyDescriptors,
|
return openReadOnly(options, path, columnFamilyDescriptors,
|
||||||
columnFamilyHandles);
|
columnFamilyHandles);
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,7 @@ public class RocksDB extends RocksObject {
|
||||||
* options instance have been closed. If user doesn't call options dispose
|
* options instance have been closed. If user doesn't call options dispose
|
||||||
* explicitly,then this options instance will be GC'd automatically.</p>
|
* explicitly,then this options instance will be GC'd automatically.</p>
|
||||||
*
|
*
|
||||||
* @param options {@link Options} instance.
|
* @param options {@link DBOptions} instance.
|
||||||
* @param path the path to the RocksDB.
|
* @param path the path to the RocksDB.
|
||||||
* @param columnFamilyDescriptors list of column family descriptors
|
* @param columnFamilyDescriptors list of column family descriptors
|
||||||
* @param columnFamilyHandles will be filled with ColumnFamilyHandle instances
|
* @param columnFamilyHandles will be filled with ColumnFamilyHandle instances
|
||||||
|
@ -310,7 +310,7 @@ public class RocksDB extends RocksObject {
|
||||||
* {@link RocksDB} can not be opened.
|
* {@link RocksDB} can not be opened.
|
||||||
* @throws RocksDBException
|
* @throws RocksDBException
|
||||||
*/
|
*/
|
||||||
public static RocksDB openReadOnly(Options options, String path,
|
public static RocksDB openReadOnly(DBOptions options, String path,
|
||||||
List<ColumnFamilyDescriptor> columnFamilyDescriptors,
|
List<ColumnFamilyDescriptor> columnFamilyDescriptors,
|
||||||
List<ColumnFamilyHandle> columnFamilyHandles)
|
List<ColumnFamilyHandle> columnFamilyHandles)
|
||||||
throws RocksDBException {
|
throws RocksDBException {
|
||||||
|
@ -342,7 +342,7 @@ public class RocksDB extends RocksObject {
|
||||||
return RocksDB.listColumnFamilies(options.nativeHandle_, path);
|
return RocksDB.listColumnFamilies(options.nativeHandle_, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void storeOptionsInstance(Options options) {
|
private void storeOptionsInstance(DBOptionsInterface options) {
|
||||||
options_ = options;
|
options_ = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1247,5 +1247,5 @@ public class RocksDB extends RocksObject {
|
||||||
private native void flush(long handle, long flushOptHandle,
|
private native void flush(long handle, long flushOptHandle,
|
||||||
long cfHandle) throws RocksDBException;
|
long cfHandle) throws RocksDBException;
|
||||||
|
|
||||||
protected Options options_;
|
protected DBOptionsInterface options_;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,10 @@ public class ColumnFamilyTest {
|
||||||
RocksDB db = null;
|
RocksDB db = null;
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
options.setCreateIfMissing(true);
|
options.setCreateIfMissing(true);
|
||||||
|
|
||||||
|
DBOptions dbOptions = new DBOptions();
|
||||||
|
dbOptions.setCreateIfMissing(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
db = RocksDB.open(options, db_path);
|
db = RocksDB.open(options, db_path);
|
||||||
} catch (RocksDBException e) {
|
} catch (RocksDBException e) {
|
||||||
|
@ -76,7 +80,7 @@ public class ColumnFamilyTest {
|
||||||
cfNames.add(new ColumnFamilyDescriptor("new_cf"));
|
cfNames.add(new ColumnFamilyDescriptor("new_cf"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
db = RocksDB.open(options, db_path, cfNames, columnFamilyHandleList);
|
db = RocksDB.open(dbOptions, db_path, cfNames, columnFamilyHandleList);
|
||||||
assert(columnFamilyHandleList.size() == 2);
|
assert(columnFamilyHandleList.size() == 2);
|
||||||
db.put("dfkey1".getBytes(), "dfvalue".getBytes());
|
db.put("dfkey1".getBytes(), "dfvalue".getBytes());
|
||||||
db.put(columnFamilyHandleList.get(0), "dfkey2".getBytes(),
|
db.put(columnFamilyHandleList.get(0), "dfkey2".getBytes(),
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class KeyMayExistTest {
|
||||||
|
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
RocksDB db;
|
RocksDB db;
|
||||||
Options options = new Options();
|
DBOptions options = new DBOptions();
|
||||||
options.setCreateIfMissing(true)
|
options.setCreateIfMissing(true)
|
||||||
.setCreateMissingColumnFamilies(true);
|
.setCreateMissingColumnFamilies(true);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -7,7 +7,6 @@ package org.rocksdb.test;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import org.rocksdb.*;
|
import org.rocksdb.*;
|
||||||
|
|
||||||
public class MergeTest {
|
public class MergeTest {
|
||||||
|
@ -41,10 +40,9 @@ public class MergeTest {
|
||||||
|
|
||||||
public static void testCFStringOption()
|
public static void testCFStringOption()
|
||||||
throws InterruptedException, RocksDBException {
|
throws InterruptedException, RocksDBException {
|
||||||
Options opt = new Options();
|
DBOptions opt = new DBOptions();
|
||||||
opt.setCreateIfMissing(true);
|
opt.setCreateIfMissing(true);
|
||||||
opt.setCreateMissingColumnFamilies(true);
|
opt.setCreateMissingColumnFamilies(true);
|
||||||
opt.setMergeOperatorName("stringappend");
|
|
||||||
|
|
||||||
List<ColumnFamilyDescriptor> cfDescr =
|
List<ColumnFamilyDescriptor> cfDescr =
|
||||||
new ArrayList<ColumnFamilyDescriptor>();
|
new ArrayList<ColumnFamilyDescriptor>();
|
||||||
|
@ -102,11 +100,10 @@ public class MergeTest {
|
||||||
|
|
||||||
public static void testCFOperatorOption()
|
public static void testCFOperatorOption()
|
||||||
throws InterruptedException, RocksDBException {
|
throws InterruptedException, RocksDBException {
|
||||||
Options opt = new Options();
|
DBOptions opt = new DBOptions();
|
||||||
opt.setCreateIfMissing(true);
|
opt.setCreateIfMissing(true);
|
||||||
opt.setCreateMissingColumnFamilies(true);
|
opt.setCreateMissingColumnFamilies(true);
|
||||||
StringAppendOperator stringAppendOperator = new StringAppendOperator();
|
StringAppendOperator stringAppendOperator = new StringAppendOperator();
|
||||||
opt.setMergeOperator(stringAppendOperator);
|
|
||||||
|
|
||||||
List<ColumnFamilyDescriptor> cfDescr =
|
List<ColumnFamilyDescriptor> cfDescr =
|
||||||
new ArrayList<ColumnFamilyDescriptor>();
|
new ArrayList<ColumnFamilyDescriptor>();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user