com.streambase.liveview.client

## Class LiveResult

- java.lang.Object
- - com.streambase.liveview.client.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 Summary

    Constructors
    Constructor and Description
    `LiveResult()` Construct 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

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `aggMarkBegin(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.
    `void` | `aggMarkEnd(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.
    `void` | `deleteBegin(BeginDeleteEvent event)` Event to indicate the start of delete query.
    `void` | `deleteEnd(EndDeleteEvent event)` Event to indicate the delete query is complete.
    `void` | `exceptionRaised(QueryExceptionEvent event)` Event when an exception occurs during the query.
    `protected Long` | `getKeyForEvent(AbstractTupleEvent event, boolean remove)`
    `protected Long` | `getKeyFromEvent(AbstractTupleEvent event)`
    `Tuple` | `getTuple(KeyValue keyValue)` Get a tuple from the KeyValue obtained from an Event.
    `Collection<Tuple>` | `getTuples()` Retrieves the current tuples in the result
    `Collection<Tuple>` | `getTuples(boolean waitForSnapshot)` Retrieves the current tuples in the result
    `boolean` | `isEmpty()` Is the result empty
    `boolean` | `isSnapshotComplete()` Retreives whether or not the LiveResult is up to date.
    `void` | `queryClosed(QueryClosedEvent event)` Event when a query being listened to is closed.
    `void` | `setTimeout(int ms)` setTimeout limits the amount of time to wait for the snapshot to complete.
    `int` | `size()` The size of the result
    `void` | `snapshotBegin(BeginSnapshotEvent event)` Event to indicate the start of the result snapshot.
    `void` | `snapshotEnd(EndSnapshotEvent event)` Event to indicate the query snapshot is complete.
    `void` | `tupleAdded(TupleAddedEvent event)` Event when a new tuple is added to the result.
    `void` | `tupleRemoved(TupleRemovedEvent event)` Event when an existing tuple is removed from the result.
    `void` | `tupleUpdated(TupleUpdatedEvent event)` Event when an existing tuple in the result is updated.
    `void` | `waitForSnapshot()` Blocking call that waits for the query snapshot to complete.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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
      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 Detail

    - #### 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

          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.
      Parameters:
        `keyValue` -
      Returns:

    - #### getTuples

          public final Collection<Tuple> getTuples()

      Retrieves the current tuples in the result
      Returns:
        the collection of tuples in the result

    - #### getTuples

          public final Collection<Tuple> getTuples(boolean waitForSnapshot)

      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

          public void tupleAdded(TupleAddedEvent event)

      Event when a new tuple is added to the result.
      Specified by:
        `tupleAdded` in interface `QueryListener`
      Parameters:
        `event` - add event

    - #### getKeyFromEvent

          protected Long getKeyFromEvent(AbstractTupleEvent event)

    - #### getKeyForEvent

          protected Long getKeyForEvent(AbstractTupleEvent event,
                                        boolean remove)

    - #### tupleUpdated

          public void tupleUpdated(TupleUpdatedEvent event)

      Event when an existing tuple in the result is updated.
      Specified by:
        `tupleUpdated` in interface `QueryListener`
      Parameters:
        `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`
      Parameters:
        `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`
      Parameters:
        `event` - snapshot begin

    - #### snapshotEnd

          public void snapshotEnd(EndSnapshotEvent event)

      Event to indicate the query snapshot is complete.
      Specified by:
        `snapshotEnd` in interface `QueryListener`
      Parameters:
        `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`
      Parameters:
        `event` - exception event

    - #### queryClosed

          public void queryClosed(QueryClosedEvent event)

      Event when a query being listened to is closed.
      Specified by:
        `queryClosed` in interface `QueryListener`
      Parameters:
        `event` - query closed event

    - #### deleteBegin

          public void deleteBegin(BeginDeleteEvent event)

      Description copied from interface: `QueryListener`
      Event to indicate the start of delete query.
      Specified by:
        `deleteBegin` in interface `QueryListener`
      Parameters:
        `event` - delete begin

    - #### deleteEnd

          public void deleteEnd(EndDeleteEvent event)

      Description copied from interface: `QueryListener`
      Event to indicate the delete query is complete.
      Specified by:
        `deleteEnd` in interface `QueryListener`
      Parameters:
        `event` - delete end

    - #### 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`

    - #### 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`

    - #### isSnapshotComplete

          public boolean isSnapshotComplete()

      Retreives whether or not the LiveResult is up to date.
      Returns:
        true if the LiveResult is up to date.

Copyright © 2015–2018 Cloud Software Group, Inc.. All rights reserved.