[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
main
fyrz 10 years ago
parent f8dc5c459f
commit ca2b00277e
  1. 10
      java/org/rocksdb/test/ColumnFamilyTest.java
  2. 4
      java/org/rocksdb/test/DirectSliceTest.java
  3. 1
      java/org/rocksdb/test/FlushTest.java

@ -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());

Loading…
Cancel
Save