public interface IStreamView extends Iterator<ILogData>
Created by mwei on 1/5/17.
Modifier and Type | Interface and Description |
---|---|
static class |
IStreamView.SearchDirection
An enum representing search directions.
|
Modifier and Type | Method and Description |
---|---|
default long |
append(Object object)
Append an object to the stream, returning the global address it was
written at.
|
long |
append(Object object,
Function<TokenResponse,Boolean> acquisitionCallback,
Function<TokenResponse,Boolean> deacquisitionCallback)
Append an object to the stream, returning the global address
it was written at.
|
ILogData |
current()
Retrieve the current entry in the stream, which was the entry previously
returned by a call to next() or previous().
|
long |
find(long globalAddress,
IStreamView.SearchDirection direction)
Find the global address of the next entry in this stream,
in the direction given.
|
void |
gc(long trimMark)
Garbage collect all the trimmed entries on this stream
|
long |
getCurrentGlobalPosition()
Get the current position of the pointer in this stream (global address).
|
UUID |
getId()
Return the ID of the stream this view is for.
|
long |
getTotalUpdates()
Get total number of updates registered to this stream.
|
boolean |
hasNext()
Returns whether or not there are potentially more entries in this
stream - this function may return true even if there are no entries
remaining, as addresses may have been acquired by other clients
but not written yet, or the addresses were hole-filled, or just failed.
|
default ILogData |
next()
Retrieve the next entry from this stream, up to the tail of the stream
If there are no entries present, this function will return NULL.
|
ILogData |
nextUpTo(long maxGlobal)
Retrieve the next entry from this stream, up to the address given or the
tail of the stream.
|
ILogData |
previous()
Retrieve the previous entry in the stream.
|
default List<ILogData> |
remaining()
Retrieve all of the entries from this stream, up to the tail of this
stream.
|
List<ILogData> |
remainingUpTo(long maxGlobal)
Retrieve all of the entries from this stream, up to the address given or
the tail of the stream.
|
void |
reset()
Reset the state of this stream view, causing the next read to
start from the beginning of this stream.
|
void |
seek(long globalAddress)
Seek to the requested maxGlobal address.
|
default Spliterator<ILogData> |
spliterator()
Get a spliterator for this stream view
|
default Spliterator<ILogData> |
spliteratorUpTo(long maxGlobal)
Get a spliterator for this stream view, limiting the return
values to a specified global address.
|
default Stream<ILogData> |
stream()
Get a Java stream from this stream view.
|
default Stream<ILogData> |
streamUpTo(long maxGlobal)
Get a Java stream from this stream view, limiting
reads to a specified global address.
|
forEachRemaining, remove
UUID getId()
void reset()
void gc(long trimMark)
trimMark
- start of the active logvoid seek(long globalAddress)
globalAddress
- Address to seek tolong find(long globalAddress, IStreamView.SearchDirection direction)
globalAddress
- The global address to start searching from.direction
- The direction to search.long append(Object object, Function<TokenResponse,Boolean> acquisitionCallback, Function<TokenResponse,Boolean> deacquisitionCallback)
Optionally, provide a method to be called when an address is acquired, and also a method to be called when an address is released (due to an unsuccessful append).
object
- The object to append.acquisitionCallback
- A function to call when an address is
acquired.
It should return true to continue with the
append.deacquisitionCallback
- A function to call when an address is
released. It should return true to retry
writing.default long append(Object object)
object
- Object to append/write@Nullable default ILogData next()
@Nullable ILogData previous()
@Nullable ILogData current()
@Nullable ILogData nextUpTo(long maxGlobal)
maxGlobal
- The maximum global address to read up to.@Nonnull default List<ILogData> remaining()
Note: the default implementation is thread-safe only if the implementation of read is synchronized.
List<ILogData> remainingUpTo(long maxGlobal)
maxGlobal
- The maximum global address to read up to.boolean hasNext()
long getCurrentGlobalPosition()
default Spliterator<ILogData> spliterator()
default Spliterator<ILogData> spliteratorUpTo(long maxGlobal)
maxGlobal
- The maximum global address to read todefault Stream<ILogData> stream()
default Stream<ILogData> streamUpTo(long maxGlobal)
maxGlobal
- The maximum global address to read to.long getTotalUpdates()
Copyright © 2019 CorfuDB. All rights reserved.