Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read reverse #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -839,4 +839,10 @@ Set<? extends Position> asyncReplayEntries(
* @return whether this cursor is closed.
*/
boolean isClosed();

/**
* Checks if the cursor is read reverse mode.
* @return: whether this cursor is reading in a reverse way
*/
boolean isReadReverse();
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ void asyncAddEntry(byte[] data, int numberOfMessages, int offset, int length, Ad
* @return the ManagedCursor
* @throws ManagedLedgerException
*/
ManagedCursor openCursor(String name, InitialPosition initialPosition) throws InterruptedException,
ManagedLedgerException;
ManagedCursor openCursor(String name, InitialPosition initialPosition, boolean readReverse)
throws InterruptedException, ManagedLedgerException;

/**
* Open a ManagedCursor in this ManagedLedger.
Expand All @@ -245,8 +245,8 @@ ManagedCursor openCursor(String name, InitialPosition initialPosition) throws In
* @return the ManagedCursor
* @throws ManagedLedgerException
*/
ManagedCursor openCursor(String name, InitialPosition initialPosition, Map<String, Long> properties,
Map<String, String> cursorProperties)
ManagedCursor openCursor(String name, InitialPosition initialPosition, boolean readReverse,
Map<String, Long> properties, Map<String, String> cursorProperties)
throws InterruptedException, ManagedLedgerException;

/**
Expand All @@ -267,7 +267,7 @@ ManagedCursor openCursor(String name, InitialPosition initialPosition, Map<Strin
ManagedCursor newNonDurableCursor(Position startCursorPosition) throws ManagedLedgerException;
ManagedCursor newNonDurableCursor(Position startPosition, String subscriptionName) throws ManagedLedgerException;
ManagedCursor newNonDurableCursor(Position startPosition, String subscriptionName, InitialPosition initialPosition,
boolean isReadCompacted) throws ManagedLedgerException;
boolean isReadReverse, boolean isReadCompacted) throws ManagedLedgerException;

/**
* Delete a ManagedCursor asynchronously.
Expand Down Expand Up @@ -330,6 +330,24 @@ ManagedCursor newNonDurableCursor(Position startPosition, String subscriptionNam
*/
void asyncOpenCursor(String name, InitialPosition initialPosition, OpenCursorCallback callback, Object ctx);

/**
* Open a ManagedCursor asynchronously.
*
* @see #openCursor(String)
* @param name
* the name associated with the ManagedCursor
* @param initialPosition
* if null, the cursor will be set at latest position when first created
* @param readReverse
* if true, the cursor will read ledger from current to previous messages
* @param callback
* callback object
* @param ctx
* opaque context
*/
void asyncOpenCursor(String name, InitialPosition initialPosition, boolean readReverse,
OpenCursorCallback callback, Object ctx);

/**
* Open a ManagedCursor asynchronously.
*
Expand All @@ -348,6 +366,27 @@ ManagedCursor newNonDurableCursor(Position startPosition, String subscriptionNam
void asyncOpenCursor(String name, InitialPosition initialPosition, Map<String, Long> properties,
Map<String, String> cursorProperties, OpenCursorCallback callback, Object ctx);

/**
* Open a ManagedCursor asynchronously.
*
* @see #openCursor(String)
* @param name
* the name associated with the ManagedCursor
* @param initialPosition
* if null, the cursor will be set at latest position when first created
* @param readReverse
* if true, the cursor will read ledger from current to previous messages
* @param cursorProperties
* the properties for the Cursor
* @param callback
* callback object
* @param ctx
* opaque context
*/
void asyncOpenCursor(String name, InitialPosition initialPosition, boolean readReverse,
Map<String, Long> properties, Map<String, String> cursorProperties,
OpenCursorCallback callback, Object ctx);

/**
* Get a list of all the cursors reading from this ManagedLedger.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ public interface Position {
*/
Position getNext();

/**
* Get the position of the entry previous to this one. The returned position might point to a non-existing entry
*
* @return the position of the previous logical entry
*/
Position getPrevious();

long getLedgerId();

long getEntryId();
Expand Down
Loading