/** * <p>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).</p> * * <p>Caller should close the iterator when it is no longer needed. * The returned iterator should be closed before this db is closed. * </p> * * @return instance of iterator object. */ public RocksIterator newIterator() { return new RocksIterator(this, iterator(nativeHandle_)); }
/** * <p>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).</p> * * <p>Caller should close the iterator when it is no longer needed. * The returned iterator should be closed before this db is closed. * </p> * * @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle} * instance * @return instance of iterator object. */ public RocksIterator newIterator( final ColumnFamilyHandle columnFamilyHandle) { return new RocksIterator(this, iteratorCF(nativeHandle_, columnFamilyHandle.nativeHandle_)); }
/** * <p>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).</p> * * <p>Caller should close the iterator when it is no longer needed. * The returned iterator should be closed before this db is closed. * </p> * * @param readOptions {@link ReadOptions} instance. * @return instance of iterator object. */ public RocksIterator newIterator(final ReadOptions readOptions) { return new RocksIterator(this, iterator(nativeHandle_, readOptions.nativeHandle_)); }
/** * <p>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).</p> * * <p>Caller should close the iterator when it is no longer needed. * The returned iterator should be closed before this db is closed. * </p> * * @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle} * instance * @param readOptions {@link ReadOptions} instance. * @return instance of iterator object. */ public RocksIterator newIterator(final ColumnFamilyHandle columnFamilyHandle, final ReadOptions readOptions) { return new RocksIterator(this, iteratorCF(nativeHandle_, columnFamilyHandle.nativeHandle_, readOptions.nativeHandle_)); }
/** * Returns iterators from a consistent database state across multiple * column families. Iterators are heap allocated and need to be deleted * before the db is deleted * * @param columnFamilyHandleList {@link java.util.List} containing * {@link org.rocksdb.ColumnFamilyHandle} instances. * @param readOptions {@link ReadOptions} instance. * @return {@link java.util.List} containing {@link org.rocksdb.RocksIterator} * instances * * @throws RocksDBException thrown if error happens in underlying * native library. */ public List<RocksIterator> newIterators( final List<ColumnFamilyHandle> columnFamilyHandleList, final ReadOptions readOptions) throws RocksDBException { final long[] columnFamilyHandles = new long[columnFamilyHandleList.size()]; for (int i = 0; i < columnFamilyHandleList.size(); i++) { columnFamilyHandles[i] = columnFamilyHandleList.get(i).nativeHandle_; } final long[] iteratorRefs = iterators(nativeHandle_, columnFamilyHandles, readOptions.nativeHandle_); final List<RocksIterator> iterators = new ArrayList<>( columnFamilyHandleList.size()); for (int i=0; i<columnFamilyHandleList.size(); i++){ iterators.add(new RocksIterator(this, iteratorRefs[i])); } return iterators; }
/** * Returns an iterator that will iterate on all keys in the default * column family including both keys in the DB and uncommitted keys in this * transaction. * * Setting {@link ReadOptions#setSnapshot(Snapshot)} will affect what is read * from the DB but will NOT change which keys are read from this transaction * (the keys in this transaction do not yet belong to any snapshot and will be * fetched regardless). * * Caller is responsible for deleting the returned Iterator. * * The returned iterator is only valid until {@link #commit()}, * {@link #rollback()}, or {@link #rollbackToSavePoint()} is called. * * @param readOptions Read options. * * @return instance of iterator object. */ public RocksIterator getIterator(final ReadOptions readOptions) { assert(isOwningHandle()); return new RocksIterator(parent, getIterator(nativeHandle_, readOptions.nativeHandle_)); }
/** * Provides Read-Your-Own-Writes like functionality by * creating a new Iterator that will use {@link org.rocksdb.WBWIRocksIterator} * as a delta and baseIterator as a base * * Updating write batch with the current key of the iterator is not safe. * We strongly recommand users not to do it. It will invalidate the current * key() and value() of the iterator. This invalidation happens even before * the write batch update finishes. The state may recover after Next() is * called. * * @param columnFamilyHandle The column family to iterate over * @param baseIterator The base iterator, * e.g. {@link org.rocksdb.RocksDB#newIterator()} * @return An iterator which shows a view comprised of both the database * point-in-time from baseIterator and modifications made in this write batch. */ public RocksIterator newIteratorWithBase( final ColumnFamilyHandle columnFamilyHandle, final RocksIterator baseIterator) { RocksIterator iterator = new RocksIterator( baseIterator.parent_, iteratorWithBase(nativeHandle_, columnFamilyHandle.nativeHandle_, baseIterator.nativeHandle_)); //when the iterator is deleted it will also delete the baseIterator baseIterator.disOwnNativeHandle(); return iterator; }
/** * Returns an iterator that will iterate on all keys in the default * column family including both keys in the DB and uncommitted keys in this * transaction. * * Setting {@link ReadOptions#setSnapshot(Snapshot)} will affect what is read * from the DB but will NOT change which keys are read from this transaction * (the keys in this transaction do not yet belong to any snapshot and will be * fetched regardless). * * Caller is responsible for calling {@link RocksIterator#close()} on * the returned Iterator. * * The returned iterator is only valid until {@link #commit()}, * {@link #rollback()}, or {@link #rollbackToSavePoint()} is called. * * @param readOptions Read options. * @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle} * instance * * @return instance of iterator object. */ public RocksIterator getIterator(final ReadOptions readOptions, final ColumnFamilyHandle columnFamilyHandle) { assert(isOwningHandle()); return new RocksIterator(parent, getIterator(nativeHandle_, readOptions.nativeHandle_, columnFamilyHandle.nativeHandle_)); }