main
Ankit Gupta 11 years ago
parent 06b590dd7c
commit 1574e0c41a
  1. 3
      java/org/rocksdb/Iterator.java
  2. 2
      java/org/rocksdb/RocksDB.java
  3. 12
      java/rocksjni/iterator.cc
  4. 4
      java/rocksjni/portal.h
  5. 5
      java/rocksjni/rocksjni.cc

@ -109,8 +109,9 @@ public class Iterator {
* If an error has occurred, return it. Else return an ok status. * If an error has occurred, return it. Else return an ok status.
* If non-blocking IO is requested and this operation cannot be * If non-blocking IO is requested and this operation cannot be
* satisfied without doing some IO, then this returns Status::Incomplete(). * satisfied without doing some IO, then this returns Status::Incomplete().
*
*/ */
public void status(){ public void status() throws RocksDBException {
assert(isInitialized()); assert(isInitialized());
status0(nativeHandle_); status0(nativeHandle_);
} }

@ -143,6 +143,8 @@ public class RocksDB {
* *
* Caller should close the iterator when it is no longer needed. * Caller should close the iterator when it is no longer needed.
* The returned iterator should be closed before this db is closed. * The returned iterator should be closed before this db is closed.
*
* @return instance of iterator object.
*/ */
public Iterator newIterator() { public Iterator newIterator() {
return new Iterator(iterator0(nativeHandle_)); return new Iterator(iterator0(nativeHandle_));

@ -80,9 +80,9 @@ jbyteArray Java_org_rocksdb_Iterator_key0(
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());
env->SetByteArrayRegion( env->SetByteArrayRegion(
jkey, 0, key_slice.size(), jkey, 0, key_slice.size(),
reinterpret_cast<const jbyte*>(key_slice.data())); reinterpret_cast<const jbyte*>(key_slice.data()));
return jkey; return jkey;
} }
@ -97,9 +97,9 @@ jbyteArray Java_org_rocksdb_Iterator_value0(
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());
env->SetByteArrayRegion( env->SetByteArrayRegion(
jvalue, 0, value_slice.size(), jvalue, 0, value_slice.size(),
reinterpret_cast<const jbyte*>(value_slice.data())); reinterpret_cast<const jbyte*>(value_slice.data()));
return jvalue; return jvalue;
} }

@ -224,7 +224,7 @@ class IteratorJni {
} }
// Get the field id of the member variable of org.rocksdb.Iterator // Get the field id of the member variable of org.rocksdb.Iterator
// that stores the pointer to rocksdb::Iterator // that stores the pointer to rocksdb::Iterator.
static jfieldID getHandleFieldID(JNIEnv* env) { static jfieldID getHandleFieldID(JNIEnv* env) {
static jfieldID fid = env->GetFieldID( static jfieldID fid = env->GetFieldID(
getJClass(env), "nativeHandle_", "J"); getJClass(env), "nativeHandle_", "J");
@ -232,7 +232,7 @@ class IteratorJni {
return fid; return fid;
} }
// Get the pointer to rocksdb::Iterator // Get the pointer to rocksdb::Iterator.
static rocksdb::Iterator* getHandle(JNIEnv* env, jobject jobj) { static rocksdb::Iterator* getHandle(JNIEnv* env, jobject jobj) {
return reinterpret_cast<rocksdb::Iterator*>( return reinterpret_cast<rocksdb::Iterator*>(
env->GetLongField(jobj, getHandleFieldID(env))); env->GetLongField(jobj, getHandleFieldID(env)));

@ -297,6 +297,11 @@ void Java_org_rocksdb_RocksDB_close0(
rocksdb::RocksDBJni::setHandle(env, java_db, nullptr); rocksdb::RocksDBJni::setHandle(env, java_db, nullptr);
} }
/*
* Class: org_rocksdb_RocksDB
* Method: iterator0
* Signature: (J)J
*/
jlong Java_org_rocksdb_RocksDB_iterator0( jlong Java_org_rocksdb_RocksDB_iterator0(
JNIEnv* env, jobject jdb, jlong db_handle) { JNIEnv* env, jobject jdb, jlong db_handle) {
auto db = reinterpret_cast<rocksdb::DB*>(db_handle); auto db = reinterpret_cast<rocksdb::DB*>(db_handle);

Loading…
Cancel
Save