]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/main/java/org/rocksdb/TransactionLogIterator.java
1 // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
5 * <p>A TransactionLogIterator is used to iterate over the transactions in a db.
6 * One run of the iterator is continuous, i.e. the iterator will stop at the
7 * beginning of any gap in sequences.</p>
9 public class TransactionLogIterator
extends RocksObject
{
12 * <p>An iterator is either positioned at a WriteBatch
13 * or not valid. This method returns true if the iterator
14 * is valid. Can read data from a valid iterator.</p>
16 * @return true if iterator position is valid.
18 public boolean isValid() {
19 return isValid(nativeHandle_
);
23 * <p>Moves the iterator to the next WriteBatch.
24 * <strong>REQUIRES</strong>: Valid() to be true.</p>
31 * <p>Throws RocksDBException if something went wrong.</p>
33 * @throws org.rocksdb.RocksDBException if something went
34 * wrong in the underlying C++ code.
36 public void status() throws RocksDBException
{
37 status(nativeHandle_
);
41 * <p>If iterator position is valid, return the current
42 * write_batch and the sequence number of the earliest
43 * transaction contained in the batch.</p>
45 * <p>ONLY use if Valid() is true and status() is OK.</p>
47 * @return {@link org.rocksdb.TransactionLogIterator.BatchResult}
50 public BatchResult
getBatch() {
52 return getBatch(nativeHandle_
);
56 * <p>TransactionLogIterator constructor.</p>
58 * @param nativeHandle address to native address.
60 TransactionLogIterator(final long nativeHandle
) {
65 * <p>BatchResult represents a data structure returned
66 * by a TransactionLogIterator containing a sequence
67 * number and a {@link WriteBatch} instance.</p>
69 public static final class BatchResult
{
71 * <p>Constructor of BatchResult class.</p>
73 * @param sequenceNumber related to this BatchResult instance.
74 * @param nativeHandle to {@link org.rocksdb.WriteBatch}
77 public BatchResult(final long sequenceNumber
,
78 final long nativeHandle
) {
79 sequenceNumber_
= sequenceNumber
;
80 writeBatch_
= new WriteBatch(nativeHandle
, true);
84 * <p>Return sequence number related to this BatchResult.</p>
86 * @return Sequence number.
88 public long sequenceNumber() {
89 return sequenceNumber_
;
93 * <p>Return contained {@link org.rocksdb.WriteBatch}
96 * @return {@link org.rocksdb.WriteBatch} instance.
98 public WriteBatch
writeBatch() {
102 private final long sequenceNumber_
;
103 private final WriteBatch writeBatch_
;
106 @Override protected final native void disposeInternal(final long handle
);
107 private native boolean isValid(long handle
);
108 private native void next(long handle
);
109 private native void status(long handle
)
110 throws RocksDBException
;
111 private native BatchResult
getBatch(long handle
);