Class LiveResult

  • All Implemented Interfaces:
    QueryListener, EventListener

    public class LiveResult
    extends Object
    implements QueryListener
    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 Detail

      • LiveResult

        public LiveResult​(QueryListener listener)
        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
        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 Detail

      • setTimeout

        public void setTimeout​(int ms)
        setTimeout limits the amount of time to wait for the snapshot to complete.
        ms - - number of milliseconds to wait before abandoning waiting for snapshot complete.
      • isEmpty

        public final boolean isEmpty()
        Is the result empty
        true is the result is empty
      • size

        public final int size()
        The size of the result
        the size
      • getTuple

        public Tuple getTuple​(KeyValue keyValue)
        Get a tuple from the KeyValue obtained from an Event. Note that this will return null if the tuple is not in the list of tuples, that is, before it has been added or after it has been removed.
        keyValue - of type KeyValue.
      • getTuples

        public final Collection<Tuple> getTuples()
        Retrieves the current tuples in the result.
        the collection of tuples in the result.
      • getTuples

        public final Collection<Tuple> getTuples​(boolean waitForSnapshot)
        Retrieves the current tuples in the result
        waitForSnapshot - waits for the query snapshot to complete before returning from the call
        the collection of tuples in the result
      • waitForSnapshot

        public final void waitForSnapshot()
        Blocking call that waits for the query snapshot to complete.
      • tupleUpdated

        public void tupleUpdated​(TupleUpdatedEvent event)
        Event when an existing tuple in the result is updated.
        Specified by:
        tupleUpdated in interface QueryListener
        event - update event
      • tupleRemoved

        public void tupleRemoved​(TupleRemovedEvent event)
        Event when an existing tuple is removed from the result.
        Specified by:
        tupleRemoved in interface QueryListener
        event - remove event
      • snapshotBegin

        public void snapshotBegin​(BeginSnapshotEvent event)
        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:
        snapshotBegin in interface QueryListener
        event - snapshot begin
      • snapshotEnd

        public void snapshotEnd​(EndSnapshotEvent event)
        Event to indicate the query snapshot is complete.
        Specified by:
        snapshotEnd in interface QueryListener
        event - snapshot end
      • exceptionRaised

        public void exceptionRaised​(QueryExceptionEvent event)
        Event when an exception occurs during the query. Since 1.3, reaching the row limit is considered an exception.
        Specified by:
        exceptionRaised in interface QueryListener
        event - exception event
      • queryClosed

        public void queryClosed​(QueryClosedEvent event)
        Event when a query being listened to is closed.
        Specified by:
        queryClosed in interface QueryListener
        event - query closed event
      • aggMarkEnd

        public void aggMarkEnd​(EndAggMarkEvent event)
        Description copied from interface: QueryListener
        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.
        Specified by:
        aggMarkEnd in interface QueryListener
        event - the EndAggMarkEvent
      • aggMarkBegin

        public void aggMarkBegin​(BeginAggMarkEvent event)
        Description copied from interface: QueryListener
        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.
        Specified by:
        aggMarkBegin in interface QueryListener
        event - the BeginAggMarkEvent
      • isSnapshotComplete

        public boolean isSnapshotComplete()
        Retreives whether or not the LiveResult is up to date.
        true if the LiveResult is up to date.