diff --git a/java/org/rocksdb/Iterator.java b/java/org/rocksdb/Iterator.java index eddf8cc49d84274bfc91e5e601dfcaa2eba623ff..c34deab3596b89ff110cd3640aae4f6ec62242a6 100644 --- a/java/org/rocksdb/Iterator.java +++ b/java/org/rocksdb/Iterator.java @@ -8,12 +8,12 @@ package org.rocksdb; /** * An iterator yields a sequence of key/value pairs from a source. * The following class defines the interface. Multiple implementations - * are provided by this library. In particular, iterators are provided + * are provided by this library. In particular, iterators are provided * to access the contents of a Table or a DB. - * - * Multiple threads can invoke const methods on an Iterator without + * + * Multiple threads can invoke const methods on an Iterator without * external synchronization, but if any of the threads may call a - * non-const method, all threads accessing the same Iterator must use + * non-const method, all threads accessing the same Iterator must use * external synchronization. */ public class Iterator { @@ -50,7 +50,7 @@ public class Iterator { assert(isInitialized()); seekToLast0(nativeHandle_); } - + /** * Moves to the next entry in the source. After this call, Valid() is * true iff the iterator was not positioned at the last entry in the source. @@ -60,7 +60,7 @@ public class Iterator { assert(isInitialized()); next0(nativeHandle_); } - + /** * Moves to the previous entry in the source. After this call, Valid() is * true iff the iterator was not positioned at the first entry in source. @@ -73,7 +73,7 @@ public class Iterator { /** * Return the key for the current entry. The underlying storage for - * the returned slice is valid only until the next modification of + * the returned slice is valid only until the next modification of * the iterator. * REQUIRES: Valid() * @return key for the current entry. @@ -84,9 +84,9 @@ public class Iterator { } /** - * Return the value for the current entry. The underlying storage for - * the returned slice is valid only until the next modification of - * the iterator. + * Return the value for the current entry. The underlying storage for + * the returned slice is valid only until the next modification of + * the iterator. * REQUIRES: !AtEnd() && !AtStart() * @return value for the current entry. */ @@ -106,11 +106,12 @@ public class Iterator { } /** - * If an error has occurred, return it. Else return an ok status. - * If non-blocking IO is requested and this operation cannot be + * If an error has occurred, return it. Else return an ok status. + * If non-blocking IO is requested and this operation cannot be * satisfied without doing some IO, then this returns Status::Incomplete(). + * */ - public void status(){ + public void status() throws RocksDBException { assert(isInitialized()); status0(nativeHandle_); } diff --git a/java/org/rocksdb/RocksDB.java b/java/org/rocksdb/RocksDB.java index b43764f8f676d931b6ce98b248879f6284f8ea30..38426d50ce08992b9008d3c54319c87c7d6d6269 100644 --- a/java/org/rocksdb/RocksDB.java +++ b/java/org/rocksdb/RocksDB.java @@ -140,9 +140,11 @@ public class RocksDB { * Return a heap-allocated iterator over the contents of the database. * The result of newIterator() is initially invalid (caller must * call one of the Seek methods on the iterator before using it). - * + * * Caller should close the iterator when it is no longer needed. * The returned iterator should be closed before this db is closed. + * + * @return instance of iterator object. */ public Iterator newIterator() { return new Iterator(iterator0(nativeHandle_)); diff --git a/java/rocksjni/iterator.cc b/java/rocksjni/iterator.cc index 378e013e057119dcc1975ee18e1026d43d30d821..7b83991c736807897f85a4ccf966e0b25f9970ec 100644 --- a/java/rocksjni/iterator.cc +++ b/java/rocksjni/iterator.cc @@ -80,9 +80,9 @@ jbyteArray Java_org_rocksdb_Iterator_key0( rocksdb::Slice key_slice = it->key(); jbyteArray jkey = env->NewByteArray(key_slice.size()); - env->SetByteArrayRegion( - jkey, 0, key_slice.size(), - reinterpret_cast(key_slice.data())); + env->SetByteArrayRegion( + jkey, 0, key_slice.size(), + reinterpret_cast(key_slice.data())); return jkey; } @@ -97,9 +97,9 @@ jbyteArray Java_org_rocksdb_Iterator_value0( rocksdb::Slice value_slice = it->value(); jbyteArray jvalue = env->NewByteArray(value_slice.size()); - env->SetByteArrayRegion( - jvalue, 0, value_slice.size(), - reinterpret_cast(value_slice.data())); + env->SetByteArrayRegion( + jvalue, 0, value_slice.size(), + reinterpret_cast(value_slice.data())); return jvalue; } diff --git a/java/rocksjni/portal.h b/java/rocksjni/portal.h index f6eabe2f155870c66a4f4b2e6fe2b0fcb1efdc82..fea01bcc52474111cf9feb1adbaa5cef3ace0ab3 100644 --- a/java/rocksjni/portal.h +++ b/java/rocksjni/portal.h @@ -224,7 +224,7 @@ class IteratorJni { } // 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 fid = env->GetFieldID( getJClass(env), "nativeHandle_", "J"); @@ -232,7 +232,7 @@ class IteratorJni { return fid; } - // Get the pointer to rocksdb::Iterator + // Get the pointer to rocksdb::Iterator. static rocksdb::Iterator* getHandle(JNIEnv* env, jobject jobj) { return reinterpret_cast( env->GetLongField(jobj, getHandleFieldID(env))); diff --git a/java/rocksjni/rocksjni.cc b/java/rocksjni/rocksjni.cc index 877ba063b6aa6f5e0b3bd60ef4416b0ec832e241..f3f9c831b94c1a21fa24f8865dac9c0ee13144e6 100644 --- a/java/rocksjni/rocksjni.cc +++ b/java/rocksjni/rocksjni.cc @@ -297,6 +297,11 @@ void Java_org_rocksdb_RocksDB_close0( rocksdb::RocksDBJni::setHandle(env, java_db, nullptr); } +/* + * Class: org_rocksdb_RocksDB + * Method: iterator0 + * Signature: (J)J + */ jlong Java_org_rocksdb_RocksDB_iterator0( JNIEnv* env, jobject jdb, jlong db_handle) { auto db = reinterpret_cast(db_handle);