提交 ca2b0027 编写于 作者: F fyrz

[RocksJava] Cleanup portal.h & tests

Summary:
Simple Java Native Objects usually are represented using
the same functionality but within different classes.

With this commit a template class was introduced to remove
the redundant impelementation to a certain extent.

[RocksJava] Removed todo comment in portal.h

As jclass instances shall not be cached, both
todos are obsolete and can be removed.

[RocksJava] Add missing test to Makefile

[RocksJava] Added tests for uncovered methods

Test Plan:
make rocksdbjava
make jtest
mvn -f rocksjni.pom package

Reviewers: adamretter, yhchiang, ankgup87

Subscribers: dhruba

Differential Revision: https://reviews.facebook.net/D32145
上级 f8dc5c45
......@@ -259,7 +259,8 @@ public class ColumnFamilyTest {
new ArrayList<>();
List<ColumnFamilyHandle> columnFamilyHandleList =
new ArrayList<>();
cfNames.add(new ColumnFamilyDescriptor(RocksDB.DEFAULT_COLUMN_FAMILY));
cfNames.add(new ColumnFamilyDescriptor(RocksDB.DEFAULT_COLUMN_FAMILY,
new ColumnFamilyOptions().setMergeOperator(new StringAppendOperator())));
cfNames.add(new ColumnFamilyDescriptor("new_cf".getBytes()));
db = RocksDB.open(opt, dbFolder.getRoot().getAbsolutePath(),
......@@ -268,6 +269,10 @@ public class ColumnFamilyTest {
WriteBatch writeBatch = new WriteBatch();
WriteOptions writeOpt = new WriteOptions();
writeBatch.put("key".getBytes(), "value".getBytes());
writeBatch.put(db.getDefaultColumnFamily(),
"mergeKey".getBytes(), "merge".getBytes());
writeBatch.merge(db.getDefaultColumnFamily(), "mergeKey".getBytes(),
"merge".getBytes());
writeBatch.put(columnFamilyHandleList.get(1), "newcfkey".getBytes(),
"value".getBytes());
writeBatch.put(columnFamilyHandleList.get(1), "newcfkey2".getBytes(),
......@@ -283,6 +288,9 @@ public class ColumnFamilyTest {
assertThat(new String(db.get(columnFamilyHandleList.get(1),
"newcfkey2".getBytes()))).isEqualTo("value2");
assertThat(new String(db.get("key".getBytes()))).isEqualTo("value");
// check if key is merged
assertThat(new String(db.get(db.getDefaultColumnFamily(),
"mergeKey".getBytes()))).isEqualTo("merge,merge");
} finally {
if (db != null) {
db.close();
......
......@@ -48,8 +48,10 @@ public class DirectSliceTest {
DirectSlice directSlice = null;
try {
byte[] data = "Some text".getBytes();
ByteBuffer buffer = ByteBuffer.allocateDirect(data.length);
ByteBuffer buffer = ByteBuffer.allocateDirect(data.length + 1);
buffer.put(data);
buffer.put(data.length, (byte)0);
directSlice = new DirectSlice(buffer);
assertThat(directSlice.toString()).isEqualTo("Some text");
} finally {
......
......@@ -36,6 +36,7 @@ public class FlushTest {
wOpt = new WriteOptions();
flushOptions = new FlushOptions();
flushOptions.setWaitForFlush(true);
assertThat(flushOptions.waitForFlush()).isTrue();
wOpt.setDisableWAL(true);
db = RocksDB.open(options, dbFolder.getRoot().getAbsolutePath());
db.put(wOpt, "key1".getBytes(), "value1".getBytes());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册