rocksdb/java/org/rocksdb/RocksIterator.java

65 lines
2.3 KiB
Java
Raw Normal View History

2014-04-19 03:26:22 -07:00
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
package org.rocksdb;
2014-04-19 13:13:01 -07:00
/**
* <p>An iterator that yields a sequence of key/value pairs from a source.
* Multiple implementations are provided by this library.
* In particular, iterators are provided
* to access the contents of a Table or a DB.</p>
2014-04-19 13:21:06 -07:00
*
* <p>Multiple threads can invoke const methods on an RocksIterator without
2014-04-19 13:13:01 -07:00
* external synchronization, but if any of the threads may call a
* non-const method, all threads accessing the same RocksIterator must use
* external synchronization.</p>
*
* @see org.rocksdb.RocksObject
2014-04-19 13:13:01 -07:00
*/
public class RocksIterator extends AbstractRocksIterator<RocksDB> {
protected RocksIterator(RocksDB rocksDB, long nativeHandle) {
super(rocksDB, nativeHandle);
}
2014-04-19 13:13:01 -07:00
/**
* <p>Return the key for the current entry. The underlying storage for
2014-04-19 13:21:06 -07:00
* the returned slice is valid only until the next modification of
* the iterator.</p>
*
2014-11-06 16:25:53 +08:00
* <p>REQUIRES: {@link #isValid()}</p>
*
2014-04-19 13:13:01 -07:00
* @return key for the current entry.
*/
2014-04-19 12:55:28 -07:00
public byte[] key() {
assert(isInitialized());
return key0(nativeHandle_);
}
2014-04-19 13:05:21 -07:00
2014-04-19 13:13:01 -07:00
/**
* <p>Return the value for the current entry. The underlying storage for
2014-04-19 13:21:06 -07:00
* the returned slice is valid only until the next modification of
* the iterator.</p>
*
2014-11-06 16:25:53 +08:00
* <p>REQUIRES: !AtEnd() &amp;&amp; !AtStart()</p>
2014-04-19 13:13:01 -07:00
* @return value for the current entry.
*/
2014-04-19 12:55:28 -07:00
public byte[] value() {
assert(isInitialized());
return value0(nativeHandle_);
}
2014-04-19 13:05:21 -07:00
@Override final native void disposeInternal(long handle);
@Override final native boolean isValid0(long handle);
@Override final native void seekToFirst0(long handle);
@Override final native void seekToLast0(long handle);
@Override final native void next0(long handle);
@Override final native void prev0(long handle);
@Override final native void seek0(long handle, byte[] target, int targetLen);
@Override final native void status0(long handle) throws RocksDBException;
2014-04-19 13:05:21 -07:00
2014-04-19 12:55:28 -07:00
private native byte[] key0(long handle);
private native byte[] value0(long handle);
2014-04-19 13:05:21 -07:00
}