All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.forstdb.TransactionLogIterator Maven / Gradle / Ivy

Go to download

ForSt fat jar with modifications specific for Apache Flink that contains .so files for linux32 and linux64 (glibc and musl-libc), jnilib files for Mac OSX, and a .dll for Windows x64.

There is a newer version: 0.1.2-beta
Show newest version
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
package org.forstdb;

/**
 * 

A TransactionLogIterator is used to iterate over the transactions in a db. * One run of the iterator is continuous, i.e. the iterator will stop at the * beginning of any gap in sequences.

*/ public class TransactionLogIterator extends RocksObject { /** *

An iterator is either positioned at a WriteBatch * or not valid. This method returns true if the iterator * is valid. Can read data from a valid iterator.

* * @return true if iterator position is valid. */ public boolean isValid() { return isValid(nativeHandle_); } /** *

Moves the iterator to the next WriteBatch. * REQUIRES: Valid() to be true.

*/ public void next() { next(nativeHandle_); } /** *

Throws RocksDBException if something went wrong.

* * @throws org.forstdb.RocksDBException if something went * wrong in the underlying C++ code. */ public void status() throws RocksDBException { status(nativeHandle_); } /** *

If iterator position is valid, return the current * write_batch and the sequence number of the earliest * transaction contained in the batch.

* *

ONLY use if Valid() is true and status() is OK.

* * @return {@link org.forstdb.TransactionLogIterator.BatchResult} * instance. */ public BatchResult getBatch() { assert(isValid()); return getBatch(nativeHandle_); } /** *

TransactionLogIterator constructor.

* * @param nativeHandle address to native address. */ TransactionLogIterator(final long nativeHandle) { super(nativeHandle); } /** *

BatchResult represents a data structure returned * by a TransactionLogIterator containing a sequence * number and a {@link WriteBatch} instance.

*/ public static final class BatchResult { /** *

Constructor of BatchResult class.

* * @param sequenceNumber related to this BatchResult instance. * @param nativeHandle to {@link org.forstdb.WriteBatch} * native instance. */ public BatchResult(final long sequenceNumber, final long nativeHandle) { sequenceNumber_ = sequenceNumber; writeBatch_ = new WriteBatch(nativeHandle, true); } /** *

Return sequence number related to this BatchResult.

* * @return Sequence number. */ public long sequenceNumber() { return sequenceNumber_; } /** *

Return contained {@link org.forstdb.WriteBatch} * instance

* * @return {@link org.forstdb.WriteBatch} instance. */ public WriteBatch writeBatch() { return writeBatch_; } private final long sequenceNumber_; private final WriteBatch writeBatch_; } @Override protected final native void disposeInternal(final long handle); private native boolean isValid(long handle); private native void next(long handle); private native void status(long handle) throws RocksDBException; private native BatchResult getBatch(long handle); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy