mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
[Java] Add Java binding and Java test for ReadOptions.
Summary: Add Java binding and test for rocksdb::ReadOptions. Test Plan: make rocksdbjava make jtest Reviewers: haobo, dhruba, sdong, ankgup87, rsumbaly, swapnilghike, zzbennett Reviewed By: haobo CC: leveldb Differential Revision: https://reviews.facebook.net/D18129
This commit is contained in:
@@ -84,6 +84,9 @@ public class RocksDBSample {
|
||||
// be sure to release the c++ pointer
|
||||
db.close();
|
||||
|
||||
ReadOptions readOptions = new ReadOptions();
|
||||
readOptions.setFillCache(false);
|
||||
|
||||
try {
|
||||
db = RocksDB.open(options, db_path);
|
||||
db.put("hello".getBytes(), "world".getBytes());
|
||||
@@ -110,6 +113,8 @@ public class RocksDBSample {
|
||||
assert(value != null);
|
||||
value = db.get("world".getBytes());
|
||||
assert(value == null);
|
||||
value = db.get(readOptions, "world".getBytes());
|
||||
assert(value == null);
|
||||
|
||||
byte[] testKey = "asdf".getBytes();
|
||||
byte[] testValue =
|
||||
@@ -119,6 +124,10 @@ public class RocksDBSample {
|
||||
assert(testResult != null);
|
||||
assert(Arrays.equals(testValue, testResult));
|
||||
assert(new String(testValue).equals(new String(testResult)));
|
||||
testResult = db.get(readOptions, testKey);
|
||||
assert(testResult != null);
|
||||
assert(Arrays.equals(testValue, testResult));
|
||||
assert(new String(testValue).equals(new String(testResult)));
|
||||
|
||||
byte[] insufficientArray = new byte[10];
|
||||
byte[] enoughArray = new byte[50];
|
||||
@@ -130,6 +139,13 @@ public class RocksDBSample {
|
||||
len = db.get(testKey, enoughArray);
|
||||
assert(len == testValue.length);
|
||||
|
||||
len = db.get(readOptions, testKey, insufficientArray);
|
||||
assert(len > insufficientArray.length);
|
||||
len = db.get(readOptions, "asdfjkl;".getBytes(), enoughArray);
|
||||
assert(len == RocksDB.NOT_FOUND);
|
||||
len = db.get(readOptions, testKey, enoughArray);
|
||||
assert(len == testValue.length);
|
||||
|
||||
db.remove(testKey);
|
||||
len = db.get(testKey, enoughArray);
|
||||
assert(len == RocksDB.NOT_FOUND);
|
||||
@@ -207,5 +223,6 @@ public class RocksDBSample {
|
||||
}
|
||||
// be sure to dispose c++ pointers
|
||||
options.dispose();
|
||||
readOptions.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user