Interface EPIterable

All Known Subinterfaces:
EPStatement, EPStatementSPI
All Known Implementing Classes:
EPStatementImpl

public interface EPIterable
Interface to iterate over events.
  • Method Summary

    Modifier and Type
    Method
    Description
    Iterator<com.espertech.esper.common.client.EventBean>
    Returns a concurrency-unsafe iterator over events representing statement results (pull API).
    Iterator<com.espertech.esper.common.client.EventBean>
    iterator(com.espertech.esper.common.client.context.ContextPartitionSelector selector)
    For use with statements that have a context declared and that may therefore have multiple context partitions, allows to iterate over context partitions selectively.
    com.espertech.esper.common.client.util.SafeIterator<com.espertech.esper.common.client.EventBean>
    Returns a concurrency-safe iterator that iterates over events representing statement results (pull API) in the face of concurrent event processing by further threads.
    com.espertech.esper.common.client.util.SafeIterator<com.espertech.esper.common.client.EventBean>
    safeIterator(com.espertech.esper.common.client.context.ContextPartitionSelector selector)
    For use with statements that have a context declared and that may therefore have multiple context partitions, allows to safe-iterate over context partitions selectively.
  • Method Details

    • iterator

      Iterator<com.espertech.esper.common.client.EventBean> iterator()
      Returns a concurrency-unsafe iterator over events representing statement results (pull API).

      The iterator is useful for applications that are single-threaded, or that coordinate the iterating thread with event processing threads that use the sendEvent method using application code locks or synchronization.

      The iterator returned by this method does not make any guarantees towards correctness of results and fail-behavior, if your application processes events into the runtime instance using the sendEvent method by multiple threads.

      Use the safeIterator method for concurrency-safe iteration. Note the safe iterator requires applications to explicitly close the safe iterator when done iterating.

      Returns:
      event iterator
    • safeIterator

      com.espertech.esper.common.client.util.SafeIterator<com.espertech.esper.common.client.EventBean> safeIterator()
      Returns a concurrency-safe iterator that iterates over events representing statement results (pull API) in the face of concurrent event processing by further threads.

      In comparison to the regular iterator, the safe iterator guarantees correct results even as events are being processed by other threads. The cost is that the iterator holds one or more locks that must be released via the close method. Any locks are acquired at the time this method is called.

      This method is a blocking method. It may block until statement processing locks are released such that the safe iterator can acquire any required locks.

      An application MUST explicitly close the safe iterator instance using the close method, to release locks held by the iterator. The call to the close method should be done in a finally block to make sure the iterator gets closed.

      Multiple safe iterators may be not be used at the same time by different application threads. A single application thread may hold and use multiple safe iterators however this is discouraged.

      Returns:
      safe iterator; NOTE: Must use the close method to close the safe iterator, preferably in a finally block
    • iterator

      Iterator<com.espertech.esper.common.client.EventBean> iterator(com.espertech.esper.common.client.context.ContextPartitionSelector selector)
      For use with statements that have a context declared and that may therefore have multiple context partitions, allows to iterate over context partitions selectively.
      Parameters:
      selector - selects context partitions to consider
      Returns:
      iterator
    • safeIterator

      com.espertech.esper.common.client.util.SafeIterator<com.espertech.esper.common.client.EventBean> safeIterator(com.espertech.esper.common.client.context.ContextPartitionSelector selector)
      For use with statements that have a context declared and that may therefore have multiple context partitions, allows to safe-iterate over context partitions selectively.
      Parameters:
      selector - selects context partitions to consider
      Returns:
      safe iterator