[RocksJava] Integrated Review comments from yhchiang in D28023

This commit is contained in:
fyrz 2014-11-05 12:50:26 +01:00
parent 75010d2084
commit fa9cfc65f3
4 changed files with 19 additions and 18 deletions

View File

@ -130,14 +130,14 @@ public class RocksDB extends RocksObject {
* {@link RocksDB} can not be opened.
*
* @throws org.rocksdb.RocksDBException
* @see Options#setCreateIfMissing(boolean)
* @see DBOptions#setCreateIfMissing(boolean)
*/
public static RocksDB open(String path,
List<ColumnFamilyDescriptor> columnFamilyDescriptors,
List<ColumnFamilyHandle> columnFamilyHandles) throws RocksDBException {
// This allows to use the rocksjni default Options instead of
// the c++ one.
Options options = new Options();
DBOptions options = new DBOptions();
return open(options, path, columnFamilyDescriptors, columnFamilyHandles);
}
@ -197,7 +197,7 @@ public class RocksDB extends RocksObject {
* <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 columnFamilyDescriptors list of column family descriptors
* @param columnFamilyHandles will be filled with ColumnFamilyHandle instances
@ -206,16 +206,16 @@ public class RocksDB extends RocksObject {
* {@link RocksDB} can not be opened.
*
* @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<ColumnFamilyHandle> columnFamilyHandles)
throws RocksDBException {
RocksDB db = new RocksDB();
List<Long> cfReferences = db.open(options.nativeHandle_, path,
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)));
}
db.storeOptionsInstance(options);
@ -258,7 +258,7 @@ public class RocksDB extends RocksObject {
List<ColumnFamilyHandle> columnFamilyHandles) throws RocksDBException {
// This allows to use the rocksjni default Options instead of
// the c++ one.
Options options = new Options();
DBOptions options = new DBOptions();
return openReadOnly(options, path, columnFamilyDescriptors,
columnFamilyHandles);
}
@ -301,7 +301,7 @@ public class RocksDB extends RocksObject {
* options instance have been closed. If user doesn't call options dispose
* 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 columnFamilyDescriptors list of column family descriptors
* @param columnFamilyHandles will be filled with ColumnFamilyHandle instances
@ -310,7 +310,7 @@ public class RocksDB extends RocksObject {
* {@link RocksDB} can not be opened.
* @throws RocksDBException
*/
public static RocksDB openReadOnly(Options options, String path,
public static RocksDB openReadOnly(DBOptions options, String path,
List<ColumnFamilyDescriptor> columnFamilyDescriptors,
List<ColumnFamilyHandle> columnFamilyHandles)
throws RocksDBException {
@ -342,7 +342,7 @@ public class RocksDB extends RocksObject {
return RocksDB.listColumnFamilies(options.nativeHandle_, path);
}
private void storeOptionsInstance(Options options) {
private void storeOptionsInstance(DBOptionsInterface options) {
options_ = options;
}
@ -1247,5 +1247,5 @@ public class RocksDB extends RocksObject {
private native void flush(long handle, long flushOptHandle,
long cfHandle) throws RocksDBException;
protected Options options_;
protected DBOptionsInterface options_;
}

View File

@ -22,6 +22,10 @@ public class ColumnFamilyTest {
RocksDB db = null;
Options options = new Options();
options.setCreateIfMissing(true);
DBOptions dbOptions = new DBOptions();
dbOptions.setCreateIfMissing(true);
try {
db = RocksDB.open(options, db_path);
} catch (RocksDBException e) {
@ -76,7 +80,7 @@ public class ColumnFamilyTest {
cfNames.add(new ColumnFamilyDescriptor("new_cf"));
try {
db = RocksDB.open(options, db_path, cfNames, columnFamilyHandleList);
db = RocksDB.open(dbOptions, db_path, cfNames, columnFamilyHandleList);
assert(columnFamilyHandleList.size() == 2);
db.put("dfkey1".getBytes(), "dfvalue".getBytes());
db.put(columnFamilyHandleList.get(0), "dfkey2".getBytes(),

View File

@ -17,7 +17,7 @@ public class KeyMayExistTest {
public static void main(String[] args){
RocksDB db;
Options options = new Options();
DBOptions options = new DBOptions();
options.setCreateIfMissing(true)
.setCreateMissingColumnFamilies(true);
try {

View File

@ -7,7 +7,6 @@ package org.rocksdb.test;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import org.rocksdb.*;
public class MergeTest {
@ -41,10 +40,9 @@ public class MergeTest {
public static void testCFStringOption()
throws InterruptedException, RocksDBException {
Options opt = new Options();
DBOptions opt = new DBOptions();
opt.setCreateIfMissing(true);
opt.setCreateMissingColumnFamilies(true);
opt.setMergeOperatorName("stringappend");
List<ColumnFamilyDescriptor> cfDescr =
new ArrayList<ColumnFamilyDescriptor>();
@ -102,11 +100,10 @@ public class MergeTest {
public static void testCFOperatorOption()
throws InterruptedException, RocksDBException {
Options opt = new Options();
DBOptions opt = new DBOptions();
opt.setCreateIfMissing(true);
opt.setCreateMissingColumnFamilies(true);
StringAppendOperator stringAppendOperator = new StringAppendOperator();
opt.setMergeOperator(stringAppendOperator);
List<ColumnFamilyDescriptor> cfDescr =
new ArrayList<ColumnFamilyDescriptor>();