Add more iterator functions
This commit is contained in:
parent
5bbeefaa49
commit
eda398491a
@ -145,6 +145,9 @@ public class RocksDBSample {
|
|||||||
Iterator iterator = db.iterator();
|
Iterator iterator = db.iterator();
|
||||||
iterator.seekToFirst();
|
iterator.seekToFirst();
|
||||||
assert(iterator.isValid());
|
assert(iterator.isValid());
|
||||||
|
iterator.next();
|
||||||
|
iterator.seekToLast();
|
||||||
|
iterator.prev();
|
||||||
iterator.close();
|
iterator.close();
|
||||||
} catch (RocksDBException e) {
|
} catch (RocksDBException e) {
|
||||||
System.err.println(e);
|
System.err.println(e);
|
||||||
|
@ -22,6 +22,21 @@ public class Iterator {
|
|||||||
seekToFirst0(nativeHandle_);
|
seekToFirst0(nativeHandle_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void seekToLast() {
|
||||||
|
assert(isInitialized());
|
||||||
|
seekToLast0(nativeHandle_);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void next() {
|
||||||
|
assert(isInitialized());
|
||||||
|
next0(nativeHandle_);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void prev() {
|
||||||
|
assert(isInitialized());
|
||||||
|
prev0(nativeHandle_);
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void close() {
|
public synchronized void close() {
|
||||||
if(nativeHandle_ != 0) {
|
if(nativeHandle_ != 0) {
|
||||||
close0(nativeHandle_);
|
close0(nativeHandle_);
|
||||||
@ -39,4 +54,7 @@ public class Iterator {
|
|||||||
private native boolean isValid0(long handle);
|
private native boolean isValid0(long handle);
|
||||||
private native void close0(long handle);
|
private native void close0(long handle);
|
||||||
private native void seekToFirst0(long handle);
|
private native void seekToFirst0(long handle);
|
||||||
|
private native void seekToLast0(long handle);
|
||||||
|
private native void next0(long handle);
|
||||||
|
private native void prev0(long handle);
|
||||||
}
|
}
|
@ -30,6 +30,30 @@ void Java_org_rocksdb_Iterator_seekToFirst0(
|
|||||||
st->SeekToFirst();
|
st->SeekToFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Java_org_rocksdb_Iterator_seekToLast0(
|
||||||
|
JNIEnv* env, jobject jobj, jlong handle) {
|
||||||
|
auto st = reinterpret_cast<rocksdb::Iterator*>(handle);
|
||||||
|
assert(st != nullptr);
|
||||||
|
|
||||||
|
st->SeekToLast();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Java_org_rocksdb_Iterator_next0(
|
||||||
|
JNIEnv* env, jobject jobj, jlong handle) {
|
||||||
|
auto st = reinterpret_cast<rocksdb::Iterator*>(handle);
|
||||||
|
assert(st != nullptr);
|
||||||
|
|
||||||
|
st->Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Java_org_rocksdb_Iterator_prev0(
|
||||||
|
JNIEnv* env, jobject jobj, jlong handle) {
|
||||||
|
auto st = reinterpret_cast<rocksdb::Iterator*>(handle);
|
||||||
|
assert(st != nullptr);
|
||||||
|
|
||||||
|
st->Prev();
|
||||||
|
}
|
||||||
|
|
||||||
void Java_org_rocksdb_Iterator_close0(
|
void Java_org_rocksdb_Iterator_close0(
|
||||||
JNIEnv* env, jobject jobj, jlong handle) {
|
JNIEnv* env, jobject jobj, jlong handle) {
|
||||||
auto st = reinterpret_cast<rocksdb::Iterator*>(handle);
|
auto st = reinterpret_cast<rocksdb::Iterator*>(handle);
|
||||||
|
Loading…
Reference in New Issue
Block a user