Merge pull request #464 from fyrz/RocksJava-Various-Fixes

[RocksJava] Fixes to latest WriteBatchWithIndex addition
main
Yueh-Hsuan Chiang 10 years ago
commit 4d9d5955ac
  1. 6
      java/org/rocksdb/AbstractRocksIterator.java
  2. 10
      java/org/rocksdb/RocksIteratorInterface.java
  3. 6
      java/org/rocksdb/test/WriteBatchWithIndexTest.java

@ -8,13 +8,13 @@ package org.rocksdb;
/** /**
* Base class implementation for Rocks Iterators * Base class implementation for Rocks Iterators
* in the Java API * in the Java API
* <p/> *
* <p>Multiple threads can invoke const methods on an RocksIterator without * <p>Multiple threads can invoke const methods on an RocksIterator without
* external synchronization, but if any of the threads may call a * external synchronization, but if any of the threads may call a
* non-const method, all threads accessing the same RocksIterator must use * non-const method, all threads accessing the same RocksIterator must use
* external synchronization.</p> * external synchronization.</p>
* *
* @param P The type of the Parent Object from which the Rocks Iterator was * @param <P> The type of the Parent Object from which the Rocks Iterator was
* created. This is used by disposeInternal to avoid double-free * created. This is used by disposeInternal to avoid double-free
* issues with the underlying C++ object. * issues with the underlying C++ object.
* @see org.rocksdb.RocksObject * @see org.rocksdb.RocksObject
@ -78,7 +78,7 @@ public abstract class AbstractRocksIterator<P extends RocksObject>
/** /**
* <p>Deletes underlying C++ iterator pointer.</p> * <p>Deletes underlying C++ iterator pointer.</p>
* <p/> *
* <p>Note: the underlying handle can only be safely deleted if the parent * <p>Note: the underlying handle can only be safely deleted if the parent
* instance related to a certain RocksIterator is still valid and initialized. * instance related to a certain RocksIterator is still valid and initialized.
* Therefore {@code disposeInternal()} checks if the parent is initialized * Therefore {@code disposeInternal()} checks if the parent is initialized

@ -10,7 +10,7 @@ package org.rocksdb;
* access to data one entry at a time. Multiple implementations * access to data one entry at a time. 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 DB and Write Batch.</p> * to access the contents of a DB and Write Batch.</p>
* <p/> *
* <p>Multiple threads can invoke const methods on an RocksIterator without * <p>Multiple threads can invoke const methods on an RocksIterator without
* external synchronization, but if any of the threads may call a * external synchronization, but if any of the threads may call a
* non-const method, all threads accessing the same RocksIterator must use * non-const method, all threads accessing the same RocksIterator must use
@ -43,7 +43,7 @@ public interface RocksIteratorInterface {
/** /**
* <p>Position at the first entry in the source whose key is that or * <p>Position at the first entry in the source whose key is that or
* past target.</p> * past target.</p>
* <p/> *
* <p>The iterator is valid after this call if the source contains * <p>The iterator is valid after this call if the source contains
* a key that comes at or past target.</p> * a key that comes at or past target.</p>
* *
@ -55,7 +55,7 @@ public interface RocksIteratorInterface {
/** /**
* <p>Moves to the next entry in the source. After this call, Valid() is * <p>Moves to the next entry in the source. After this call, Valid() is
* true if the iterator was not positioned at the last entry in the source.</p> * true if the iterator was not positioned at the last entry in the source.</p>
* <p/> *
* <p>REQUIRES: {@link #isValid()}</p> * <p>REQUIRES: {@link #isValid()}</p>
*/ */
public void next(); public void next();
@ -63,13 +63,13 @@ public interface RocksIteratorInterface {
/** /**
* <p>Moves to the previous entry in the source. After this call, Valid() is * <p>Moves to the previous entry in the source. After this call, Valid() is
* true if the iterator was not positioned at the first entry in source.</p> * true if the iterator was not positioned at the first entry in source.</p>
* <p/> *
* <p>REQUIRES: {@link #isValid()}</p> * <p>REQUIRES: {@link #isValid()}</p>
*/ */
public void prev(); public void prev();
/** /**
* <pIf an error has occurred, return it. Else return an ok status. * <p>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().</p> * satisfied without doing some IO, then this returns Status::Incomplete().</p>
* *

@ -217,19 +217,19 @@ public class WriteBatchWithIndexTest {
it.seek(key); it.seek(key);
assertThat(it.isValid()).isTrue(); assertThat(it.isValid()).isTrue();
assertThat(it.entry()).isEqualTo(expected[testOffset]); assertThat(it.entry().equals(expected[testOffset])).isTrue();
} }
//forward iterative access //forward iterative access
int i = 0; int i = 0;
for(it.seekToFirst(); it.isValid(); it.next()) { for(it.seekToFirst(); it.isValid(); it.next()) {
assertThat(it.entry()).isEqualTo(expected[i++]); assertThat(it.entry().equals(expected[i++])).isTrue();
} }
//reverse iterative access //reverse iterative access
i = expected.length - 1; i = expected.length - 1;
for(it.seekToLast(); it.isValid(); it.prev()) { for(it.seekToLast(); it.isValid(); it.prev()) {
assertThat(it.entry()).isEqualTo(expected[i--]); assertThat(it.entry().equals(expected[i--])).isTrue();
} }
} finally { } finally {

Loading…
Cancel
Save