Remove getIterator function from portal

This commit is contained in:
Ankit Gupta 2014-04-19 23:17:42 -07:00
parent 1574e0c41a
commit bbdd550b66
2 changed files with 10 additions and 23 deletions

View File

@ -21,8 +21,7 @@
*/ */
jboolean Java_org_rocksdb_Iterator_isValid0( jboolean Java_org_rocksdb_Iterator_isValid0(
JNIEnv* env, jobject jobj, jlong handle) { JNIEnv* env, jobject jobj, jlong handle) {
auto it = rocksdb::IteratorJni::getIterator(handle); return reinterpret_cast<rocksdb::Iterator*>(handle)->Valid();
return it->Valid();
} }
/* /*
@ -32,8 +31,7 @@ jboolean Java_org_rocksdb_Iterator_isValid0(
*/ */
void Java_org_rocksdb_Iterator_seekToFirst0( void Java_org_rocksdb_Iterator_seekToFirst0(
JNIEnv* env, jobject jobj, jlong handle) { JNIEnv* env, jobject jobj, jlong handle) {
auto it = rocksdb::IteratorJni::getIterator(handle); reinterpret_cast<rocksdb::Iterator*>(handle)->SeekToFirst();
it->SeekToFirst();
} }
/* /*
@ -43,8 +41,7 @@ void Java_org_rocksdb_Iterator_seekToFirst0(
*/ */
void Java_org_rocksdb_Iterator_seekToLast0( void Java_org_rocksdb_Iterator_seekToLast0(
JNIEnv* env, jobject jobj, jlong handle) { JNIEnv* env, jobject jobj, jlong handle) {
auto it = rocksdb::IteratorJni::getIterator(handle); reinterpret_cast<rocksdb::Iterator*>(handle)->SeekToLast();
it->SeekToLast();
} }
/* /*
@ -54,8 +51,7 @@ void Java_org_rocksdb_Iterator_seekToLast0(
*/ */
void Java_org_rocksdb_Iterator_next0( void Java_org_rocksdb_Iterator_next0(
JNIEnv* env, jobject jobj, jlong handle) { JNIEnv* env, jobject jobj, jlong handle) {
auto it = rocksdb::IteratorJni::getIterator(handle); reinterpret_cast<rocksdb::Iterator*>(handle)->Next();
it->Next();
} }
/* /*
@ -65,8 +61,7 @@ void Java_org_rocksdb_Iterator_next0(
*/ */
void Java_org_rocksdb_Iterator_prev0( void Java_org_rocksdb_Iterator_prev0(
JNIEnv* env, jobject jobj, jlong handle) { JNIEnv* env, jobject jobj, jlong handle) {
auto it = rocksdb::IteratorJni::getIterator(handle); reinterpret_cast<rocksdb::Iterator*>(handle)->Prev();
it->Prev();
} }
/* /*
@ -76,7 +71,7 @@ void Java_org_rocksdb_Iterator_prev0(
*/ */
jbyteArray Java_org_rocksdb_Iterator_key0( jbyteArray Java_org_rocksdb_Iterator_key0(
JNIEnv* env, jobject jobj, jlong handle) { JNIEnv* env, jobject jobj, jlong handle) {
auto it = rocksdb::IteratorJni::getIterator(handle); auto it = reinterpret_cast<rocksdb::Iterator*>(handle);
rocksdb::Slice key_slice = it->key(); rocksdb::Slice key_slice = it->key();
jbyteArray jkey = env->NewByteArray(key_slice.size()); jbyteArray jkey = env->NewByteArray(key_slice.size());
@ -93,7 +88,7 @@ jbyteArray Java_org_rocksdb_Iterator_key0(
*/ */
jbyteArray Java_org_rocksdb_Iterator_value0( jbyteArray Java_org_rocksdb_Iterator_value0(
JNIEnv* env, jobject jobj, jlong handle) { JNIEnv* env, jobject jobj, jlong handle) {
auto it = rocksdb::IteratorJni::getIterator(handle); auto it = reinterpret_cast<rocksdb::Iterator*>(handle);
rocksdb::Slice value_slice = it->value(); rocksdb::Slice value_slice = it->value();
jbyteArray jvalue = env->NewByteArray(value_slice.size()); jbyteArray jvalue = env->NewByteArray(value_slice.size());
@ -111,7 +106,7 @@ jbyteArray Java_org_rocksdb_Iterator_value0(
void Java_org_rocksdb_Iterator_seek0( void Java_org_rocksdb_Iterator_seek0(
JNIEnv* env, jobject jobj, jlong handle, JNIEnv* env, jobject jobj, jlong handle,
jbyteArray jtarget, jint jtarget_len) { jbyteArray jtarget, jint jtarget_len) {
auto it = rocksdb::IteratorJni::getIterator(handle); auto it = reinterpret_cast<rocksdb::Iterator*>(handle);
jbyte* target = env->GetByteArrayElements(jtarget, 0); jbyte* target = env->GetByteArrayElements(jtarget, 0);
rocksdb::Slice target_slice( rocksdb::Slice target_slice(
reinterpret_cast<char*>(target), jtarget_len); reinterpret_cast<char*>(target), jtarget_len);
@ -128,7 +123,7 @@ void Java_org_rocksdb_Iterator_seek0(
*/ */
void Java_org_rocksdb_Iterator_status0( void Java_org_rocksdb_Iterator_status0(
JNIEnv* env, jobject jobj, jlong handle) { JNIEnv* env, jobject jobj, jlong handle) {
auto it = rocksdb::IteratorJni::getIterator(handle); auto it = reinterpret_cast<rocksdb::Iterator*>(handle);
rocksdb::Status s = it->status(); rocksdb::Status s = it->status();
if (s.ok()) { if (s.ok()) {
@ -145,7 +140,7 @@ void Java_org_rocksdb_Iterator_status0(
*/ */
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 it = rocksdb::IteratorJni::getIterator(handle); auto it = reinterpret_cast<rocksdb::Iterator*>(handle);
delete it; delete it;
rocksdb::IteratorJni::setHandle(env, jobj, nullptr); rocksdb::IteratorJni::setHandle(env, jobj, nullptr);

View File

@ -245,14 +245,6 @@ class IteratorJni {
jobj, getHandleFieldID(env), jobj, getHandleFieldID(env),
reinterpret_cast<jlong>(op)); reinterpret_cast<jlong>(op));
} }
// Cast long to rocksdb::Iterator pointer.
static rocksdb::Iterator* getIterator(jlong handle) {
auto it = reinterpret_cast<rocksdb::Iterator*>(handle);
assert(it != nullptr);
return it;
}
}; };
} // namespace rocksdb } // namespace rocksdb
#endif // JAVA_ROCKSJNI_PORTAL_H_ #endif // JAVA_ROCKSJNI_PORTAL_H_