|
|
|
@ -14,53 +14,71 @@ |
|
|
|
|
#include "rocksjni/portal.h" |
|
|
|
|
#include "rocksdb/iterator.h" |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: org_rocksdb_Iterator |
|
|
|
|
* Method: isValid0 |
|
|
|
|
* Signature: (J)Z |
|
|
|
|
*/ |
|
|
|
|
jboolean Java_org_rocksdb_Iterator_isValid0( |
|
|
|
|
JNIEnv* env, jobject jobj, jlong handle) { |
|
|
|
|
auto st = reinterpret_cast<rocksdb::Iterator*>(handle); |
|
|
|
|
assert(st != nullptr); |
|
|
|
|
|
|
|
|
|
return st->Valid(); |
|
|
|
|
auto it = rocksdb::IteratorJni::getIterator(handle); |
|
|
|
|
return it->Valid(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: org_rocksdb_Iterator |
|
|
|
|
* Method: close0 |
|
|
|
|
* Signature: (J)V |
|
|
|
|
*/ |
|
|
|
|
void Java_org_rocksdb_Iterator_seekToFirst0( |
|
|
|
|
JNIEnv* env, jobject jobj, jlong handle) { |
|
|
|
|
auto st = reinterpret_cast<rocksdb::Iterator*>(handle); |
|
|
|
|
assert(st != nullptr); |
|
|
|
|
|
|
|
|
|
st->SeekToFirst(); |
|
|
|
|
auto it = rocksdb::IteratorJni::getIterator(handle); |
|
|
|
|
it->SeekToFirst(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: org_rocksdb_Iterator |
|
|
|
|
* Method: seekToFirst0 |
|
|
|
|
* Signature: (J)V |
|
|
|
|
*/ |
|
|
|
|
void Java_org_rocksdb_Iterator_seekToLast0( |
|
|
|
|
JNIEnv* env, jobject jobj, jlong handle) { |
|
|
|
|
auto st = reinterpret_cast<rocksdb::Iterator*>(handle); |
|
|
|
|
assert(st != nullptr); |
|
|
|
|
|
|
|
|
|
st->SeekToLast(); |
|
|
|
|
auto it = rocksdb::IteratorJni::getIterator(handle); |
|
|
|
|
it->SeekToLast(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: org_rocksdb_Iterator |
|
|
|
|
* Method: seekToLast0 |
|
|
|
|
* Signature: (J)V |
|
|
|
|
*/ |
|
|
|
|
void Java_org_rocksdb_Iterator_next0( |
|
|
|
|
JNIEnv* env, jobject jobj, jlong handle) { |
|
|
|
|
auto st = reinterpret_cast<rocksdb::Iterator*>(handle); |
|
|
|
|
assert(st != nullptr); |
|
|
|
|
|
|
|
|
|
st->Next(); |
|
|
|
|
auto it = rocksdb::IteratorJni::getIterator(handle); |
|
|
|
|
it->Next(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: org_rocksdb_Iterator |
|
|
|
|
* Method: next0 |
|
|
|
|
* Signature: (J)V |
|
|
|
|
*/ |
|
|
|
|
void Java_org_rocksdb_Iterator_prev0( |
|
|
|
|
JNIEnv* env, jobject jobj, jlong handle) { |
|
|
|
|
auto st = reinterpret_cast<rocksdb::Iterator*>(handle); |
|
|
|
|
assert(st != nullptr); |
|
|
|
|
|
|
|
|
|
st->Prev(); |
|
|
|
|
auto it = rocksdb::IteratorJni::getIterator(handle); |
|
|
|
|
it->Prev(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: org_rocksdb_Iterator |
|
|
|
|
* Method: prev0 |
|
|
|
|
* Signature: (J)V |
|
|
|
|
*/ |
|
|
|
|
jbyteArray Java_org_rocksdb_Iterator_key0( |
|
|
|
|
JNIEnv* env, jobject jobj, jlong handle) { |
|
|
|
|
auto st = reinterpret_cast<rocksdb::Iterator*>(handle); |
|
|
|
|
assert(st != nullptr); |
|
|
|
|
|
|
|
|
|
rocksdb::Slice key_slice = st->key(); |
|
|
|
|
|
|
|
|
|
auto it = rocksdb::IteratorJni::getIterator(handle); |
|
|
|
|
rocksdb::Slice key_slice = it->key(); |
|
|
|
|
|
|
|
|
|
jbyteArray jkey = env->NewByteArray(key_slice.size()); |
|
|
|
|
env->SetByteArrayRegion( |
|
|
|
|
jkey, 0, key_slice.size(), |
|
|
|
@ -68,13 +86,16 @@ jbyteArray Java_org_rocksdb_Iterator_key0( |
|
|
|
|
return jkey; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: org_rocksdb_Iterator |
|
|
|
|
* Method: key0 |
|
|
|
|
* Signature: (J)[B |
|
|
|
|
*/ |
|
|
|
|
jbyteArray Java_org_rocksdb_Iterator_value0( |
|
|
|
|
JNIEnv* env, jobject jobj, jlong handle) { |
|
|
|
|
auto st = reinterpret_cast<rocksdb::Iterator*>(handle); |
|
|
|
|
assert(st != nullptr); |
|
|
|
|
|
|
|
|
|
rocksdb::Slice value_slice = st->value(); |
|
|
|
|
|
|
|
|
|
auto it = rocksdb::IteratorJni::getIterator(handle); |
|
|
|
|
rocksdb::Slice value_slice = it->value(); |
|
|
|
|
|
|
|
|
|
jbyteArray jvalue = env->NewByteArray(value_slice.size()); |
|
|
|
|
env->SetByteArrayRegion( |
|
|
|
|
jvalue, 0, value_slice.size(), |
|
|
|
@ -82,41 +103,50 @@ jbyteArray Java_org_rocksdb_Iterator_value0( |
|
|
|
|
return jvalue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: org_rocksdb_Iterator |
|
|
|
|
* Method: value0 |
|
|
|
|
* Signature: (J)[B |
|
|
|
|
*/ |
|
|
|
|
void Java_org_rocksdb_Iterator_seek0( |
|
|
|
|
JNIEnv* env, jobject jobj, jlong handle, |
|
|
|
|
jbyteArray jtarget, jint jtarget_len) { |
|
|
|
|
auto st = reinterpret_cast<rocksdb::Iterator*>(handle); |
|
|
|
|
assert(st != nullptr); |
|
|
|
|
|
|
|
|
|
auto it = rocksdb::IteratorJni::getIterator(handle); |
|
|
|
|
jbyte* target = env->GetByteArrayElements(jtarget, 0); |
|
|
|
|
rocksdb::Slice target_slice( |
|
|
|
|
reinterpret_cast<char*>(target), jtarget_len); |
|
|
|
|
|
|
|
|
|
st->Seek(target_slice); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it->Seek(target_slice); |
|
|
|
|
|
|
|
|
|
env->ReleaseByteArrayElements(jtarget, target, JNI_ABORT); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: org_rocksdb_Iterator |
|
|
|
|
* Method: seek0 |
|
|
|
|
* Signature: (J[BI)V |
|
|
|
|
*/ |
|
|
|
|
void Java_org_rocksdb_Iterator_status0( |
|
|
|
|
JNIEnv* env, jobject jobj, jlong handle) { |
|
|
|
|
auto st = reinterpret_cast<rocksdb::Iterator*>(handle); |
|
|
|
|
assert(st != nullptr); |
|
|
|
|
|
|
|
|
|
rocksdb::Status s = st->status(); |
|
|
|
|
|
|
|
|
|
auto it = rocksdb::IteratorJni::getIterator(handle); |
|
|
|
|
rocksdb::Status s = it->status(); |
|
|
|
|
|
|
|
|
|
if (s.ok()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rocksdb::RocksDBExceptionJni::ThrowNew(env, s); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: org_rocksdb_Iterator |
|
|
|
|
* Method: status0 |
|
|
|
|
* Signature: (J)V |
|
|
|
|
*/ |
|
|
|
|
void Java_org_rocksdb_Iterator_close0( |
|
|
|
|
JNIEnv* env, jobject jobj, jlong handle) { |
|
|
|
|
auto st = reinterpret_cast<rocksdb::Iterator*>(handle); |
|
|
|
|
assert(st != nullptr); |
|
|
|
|
|
|
|
|
|
delete st; |
|
|
|
|
|
|
|
|
|
auto it = rocksdb::IteratorJni::getIterator(handle); |
|
|
|
|
delete it; |
|
|
|
|
|
|
|
|
|
rocksdb::IteratorJni::setHandle(env, jobj, nullptr); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|