Package com.streambase.liveview.client
Class LiveResult
java.lang.Object
com.streambase.liveview.client.LiveResult
- All Implemented Interfaces:
QueryListener,EventListener
A live result is a
QueryListener the receives and maintains a local copy of tuples. Methods exists to
retrieve the current list of tuples maintained locally. The live results can also be constructed with a nested
QueryListener. In this mode the live result will propagate events it received to the nested listener. It will
also modify update and remove events to include the old or removed tuple (in addition to the new tuple.)-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a LiveResult that will maintain the list of tuples for you which you can query at your leisure.LiveResult(QueryListener listener) Contruct a LiveResult that will maintain the tuples for you, plus you can also be informed of all the events. -
Method Summary
Modifier and TypeMethodDescriptionvoidaggMarkBegin(BeginAggMarkEvent event) Event to indicate that the set of aggregation results may be changing so some results may be from an older generation while other may be from a newer one.voidaggMarkEnd(EndAggMarkEvent event) Event to indicate that the set of aggregation results since the last aggMarkBegin event are now consistent and will not change until the next aggMarkBegin.voiddeleteBegin(BeginDeleteEvent event) Event to indicate the start of delete query.voiddeleteEnd(EndDeleteEvent event) Event to indicate the delete query is complete.voidEvent when an exception occurs during the query.protected LonggetKeyForEvent(AbstractTupleEvent event, boolean remove) protected LongGet a tuple from the KeyValue obtained from an Event.final Collection<Tuple> Retrieves the current tuples in the result.final Collection<Tuple> getTuples(boolean waitForSnapshot) Retrieves the current tuples in the resultfinal booleanisEmpty()Is the result emptybooleanRetreives whether or not the LiveResult is up to date.voidqueryClosed(QueryClosedEvent event) Event when a query being listened to is closed.voidsetTimeout(int ms) setTimeout limits the amount of time to wait for the snapshot to complete.final intsize()The size of the resultvoidsnapshotBegin(BeginSnapshotEvent event) Event to indicate the start of the result snapshot.voidsnapshotEnd(EndSnapshotEvent event) Event to indicate the query snapshot is complete.voidtupleAdded(TupleAddedEvent event) Event when a new tuple is added to the result.voidtupleRemoved(TupleRemovedEvent event) Event when an existing tuple is removed from the result.voidtupleUpdated(TupleUpdatedEvent event) Event when an existing tuple in the result is updated.final voidBlocking call that waits for the query snapshot to complete.
-
Constructor Details
-
LiveResult
Contruct a LiveResult that will maintain the tuples for you, plus you can also be informed of all the events. All events will be passed on to your listener. However, the update events will be populated with a complete old and new tuples. (Without the LiveResult, then update events only have the- Parameters:
listener- The listener to dispatch events to when changes occur on this LiveResult
-
LiveResult
public LiveResult()Construct a LiveResult that will maintain the list of tuples for you which you can query at your leisure.
-
-
Method Details
-
setTimeout
public void setTimeout(int ms) setTimeout limits the amount of time to wait for the snapshot to complete.- Parameters:
ms- - number of milliseconds to wait before abandoning waiting for snapshot complete.- Since:
- 1.4.1
-
isEmpty
public final boolean isEmpty()Is the result empty- Returns:
- true is the result is empty
-
size
public final int size()The size of the result- Returns:
- the size
-
getTuple
-
getTuples
Retrieves the current tuples in the result.- Returns:
- the collection of tuples in the result.
-
getTuples
Retrieves the current tuples in the result- Parameters:
waitForSnapshot- waits for the query snapshot to complete before returning from the call- Returns:
- the collection of tuples in the result
-
waitForSnapshot
public final void waitForSnapshot()Blocking call that waits for the query snapshot to complete. -
tupleAdded
Event when a new tuple is added to the result.- Specified by:
tupleAddedin interfaceQueryListener- Parameters:
event- add event- Throws:
TupleException
-
getKeyFromEvent
-
getKeyForEvent
-
tupleUpdated
Event when an existing tuple in the result is updated.- Specified by:
tupleUpdatedin interfaceQueryListener- Parameters:
event- update event
-
tupleRemoved
Event when an existing tuple is removed from the result.- Specified by:
tupleRemovedin interfaceQueryListener- Parameters:
event- remove event
-
snapshotBegin
Event to indicate the start of the result snapshot. This is the first method called when a query starts returning results, but this method is also called to indicate a reset (a complete restart of the query.)- Specified by:
snapshotBeginin interfaceQueryListener- Parameters:
event- snapshot begin
-
snapshotEnd
Event to indicate the query snapshot is complete.- Specified by:
snapshotEndin interfaceQueryListener- Parameters:
event- snapshot end
-
exceptionRaised
Event when an exception occurs during the query. Since 1.3, reaching the row limit is considered an exception.- Specified by:
exceptionRaisedin interfaceQueryListener- Parameters:
event- exception event
-
queryClosed
Event when a query being listened to is closed.- Specified by:
queryClosedin interfaceQueryListener- Parameters:
event- query closed event
-
deleteBegin
Description copied from interface:QueryListenerEvent to indicate the start of delete query.- Specified by:
deleteBeginin interfaceQueryListener- Parameters:
event- delete begin
-
deleteEnd
Description copied from interface:QueryListenerEvent to indicate the delete query is complete.- Specified by:
deleteEndin interfaceQueryListener- Parameters:
event- delete end
-
aggMarkEnd
Description copied from interface:QueryListenerEvent to indicate that the set of aggregation results since the last aggMarkBegin event are now consistent and will not change until the next aggMarkBegin.- Specified by:
aggMarkEndin interfaceQueryListener- Parameters:
event- theEndAggMarkEvent
-
aggMarkBegin
Description copied from interface:QueryListenerEvent to indicate that the set of aggregation results may be changing so some results may be from an older generation while other may be from a newer one.- Specified by:
aggMarkBeginin interfaceQueryListener- Parameters:
event- theBeginAggMarkEvent
-
isSnapshotComplete
public boolean isSnapshotComplete()Retreives whether or not the LiveResult is up to date.- Returns:
- true if the LiveResult is up to date.
-