From fa9cfc65f343f8530fb99712ba1e522bff067519 Mon Sep 17 00:00:00 2001
From: fyrz
Date: Wed, 5 Nov 2014 12:50:26 +0100
Subject: [PATCH] [RocksJava] Integrated Review comments from yhchiang in
D28023
---
java/org/rocksdb/RocksDB.java | 22 ++++++++++-----------
java/org/rocksdb/test/ColumnFamilyTest.java | 6 +++++-
java/org/rocksdb/test/KeyMayExistTest.java | 2 +-
java/org/rocksdb/test/MergeTest.java | 7 ++-----
4 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/java/org/rocksdb/RocksDB.java b/java/org/rocksdb/RocksDB.java
index 4b580f81f..c62c2f160 100644
--- a/java/org/rocksdb/RocksDB.java
+++ b/java/org/rocksdb/RocksDB.java
@@ -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 columnFamilyDescriptors,
List 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 {
*
* ColumnFamily handles are disposed when the RocksDB instance is disposed.
*
- * @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 columnFamilyDescriptors,
List columnFamilyHandles)
throws RocksDBException {
RocksDB db = new RocksDB();
List cfReferences = db.open(options.nativeHandle_, path,
columnFamilyDescriptors, columnFamilyDescriptors.size());
- for (int i=0; i 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.
*
- * @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 columnFamilyDescriptors,
List 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_;
}
diff --git a/java/org/rocksdb/test/ColumnFamilyTest.java b/java/org/rocksdb/test/ColumnFamilyTest.java
index 38f6df7f8..0f3ee0c25 100644
--- a/java/org/rocksdb/test/ColumnFamilyTest.java
+++ b/java/org/rocksdb/test/ColumnFamilyTest.java
@@ -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(),
diff --git a/java/org/rocksdb/test/KeyMayExistTest.java b/java/org/rocksdb/test/KeyMayExistTest.java
index e3b4ed763..03be46fbe 100644
--- a/java/org/rocksdb/test/KeyMayExistTest.java
+++ b/java/org/rocksdb/test/KeyMayExistTest.java
@@ -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 {
diff --git a/java/org/rocksdb/test/MergeTest.java b/java/org/rocksdb/test/MergeTest.java
index e3c70c885..d802559e1 100644
--- a/java/org/rocksdb/test/MergeTest.java
+++ b/java/org/rocksdb/test/MergeTest.java
@@ -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 cfDescr =
new ArrayList();
@@ -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 cfDescr =
new ArrayList();