]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/main/java/org/rocksdb/RocksIterator.java
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / rocksdb / java / src / main / java / org / rocksdb / RocksIterator.java
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under the BSD-style license found in the
3 // LICENSE file in the root directory of this source tree. An additional grant
4 // of patent rights can be found in the PATENTS file in the same directory.
5
6 package org.rocksdb;
7
8 /**
9 * <p>An iterator that yields a sequence of key/value pairs from a source.
10 * Multiple implementations are provided by this library.
11 * In particular, iterators are provided
12 * to access the contents of a Table or a DB.</p>
13 *
14 * <p>Multiple threads can invoke const methods on an RocksIterator without
15 * external synchronization, but if any of the threads may call a
16 * non-const method, all threads accessing the same RocksIterator must use
17 * external synchronization.</p>
18 *
19 * @see org.rocksdb.RocksObject
20 */
21 public class RocksIterator extends AbstractRocksIterator<RocksDB> {
22 protected RocksIterator(RocksDB rocksDB, long nativeHandle) {
23 super(rocksDB, nativeHandle);
24 }
25
26 /**
27 * <p>Return the key for the current entry. The underlying storage for
28 * the returned slice is valid only until the next modification of
29 * the iterator.</p>
30 *
31 * <p>REQUIRES: {@link #isValid()}</p>
32 *
33 * @return key for the current entry.
34 */
35 public byte[] key() {
36 assert(isOwningHandle());
37 return key0(nativeHandle_);
38 }
39
40 /**
41 * <p>Return the value for the current entry. The underlying storage for
42 * the returned slice is valid only until the next modification of
43 * the iterator.</p>
44 *
45 * <p>REQUIRES: !AtEnd() &amp;&amp; !AtStart()</p>
46 * @return value for the current entry.
47 */
48 public byte[] value() {
49 assert(isOwningHandle());
50 return value0(nativeHandle_);
51 }
52
53 @Override protected final native void disposeInternal(final long handle);
54 @Override final native boolean isValid0(long handle);
55 @Override final native void seekToFirst0(long handle);
56 @Override final native void seekToLast0(long handle);
57 @Override final native void next0(long handle);
58 @Override final native void prev0(long handle);
59 @Override final native void seek0(long handle, byte[] target, int targetLen);
60 @Override final native void status0(long handle) throws RocksDBException;
61
62 private native byte[] key0(long handle);
63 private native byte[] value0(long handle);
64 }