Class RollingEventBuffer

java.lang.Object
com.espertech.esper.common.internal.collection.RollingEventBuffer

public class RollingEventBuffer extends Object
Event buffer of a given size provides a random access API into the most current event to prior events up to the given size. Oldest events roll out of the buffer first.

Backed by a fixed-size array that is filled forward, then rolls back to the beginning keeping track of the current position.

  • Constructor Details

    • RollingEventBuffer

      public RollingEventBuffer(int size)
      Ctor.
      Parameters:
      size - is the maximum number of events in buffer
  • Method Details

    • add

      public void add(EventBean[] events)
      Add events to the buffer.
      Parameters:
      events - to add
    • add

      public void add(EventBean theEvent)
      Add an event to the buffer.
      Parameters:
      theEvent - to add
    • get

      public EventBean get(int index)
      Get an event prior to the last event posted given a number of events before the last.

      Thus index 0 returns the last event added, index 1 returns the prior to the last event added up to the maximum buffer size.

      Parameters:
      index - prior event index from zero to max size
      Returns:
      prior event at given index
    • getSize

      public int getSize()
    • getBuffer

      public EventBean[] getBuffer()
    • getNextFreeIndex

      public int getNextFreeIndex()
    • setBuffer

      public void setBuffer(EventBean[] buffer)
    • setNextFreeIndex

      public void setNextFreeIndex(int nextFreeIndex)