com.espertech.esper.view.internal
Class PriorEventBufferSingle

java.lang.Object
  extended by com.espertech.esper.view.internal.PriorEventBufferSingle
All Implemented Interfaces:
ViewUpdatedCollection, RelativeAccessByEventNIndex

public class PriorEventBufferSingle
extends java.lang.Object
implements ViewUpdatedCollection, RelativeAccessByEventNIndex

Buffers view-posted insert stream (new data) and remove stream (old data) events for use with serving prior results in these streams, for a single prior event.

Buffers only exactly those events in new data and old data that are being asked for via the 2 or more 'prior' functions that specify different indexes. For example "select prior(2, price), prior(1, price)" results in on buffer instance handling both the need to the immediatly prior (1) and the 2-events-ago event (2).

As all views are required to post new data and post old data that removes the new data to subsequent views, this buffer can be attached to all views and should not result in a memory leak.

When the buffer receives old data (rstream) events it removes the prior events to the rstream events from the buffer the next time it receives a post (not immediatly) to allow queries to the buffer.


Constructor Summary
PriorEventBufferSingle(int priorEventIndex)
          Ctor.
 
Method Summary
 void destroy()
          De-allocate resources held by the collection.
 RollingEventBuffer getNewEvents()
           
 int getNumEventsInsertBuf()
           
 java.util.Map<EventBean,EventBean> getPriorEventMap()
           
 EventBean getRelativeToEnd(EventBean theEvent, int index)
           
 EventBean getRelativeToEvent(EventBean theEvent, int priorToIndex)
          Returns the prior event to the given event counting back the number of events as supplied by index.
 java.util.Iterator<EventBean> getWindowToEvent(java.lang.Object evalEvent)
           
 java.util.Collection<EventBean> getWindowToEventCollReadOnly(java.lang.Object evalEvent)
           
 int getWindowToEventCount(EventBean evalEvent)
           
 void update(EventBean[] newData, EventBean[] oldData)
          Accepts view insert and remove stream.
 void update(EventBean[] newData, EventBean[] oldData, PriorEventBufferChangeCaptureSingle captureSingle)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PriorEventBufferSingle

public PriorEventBufferSingle(int priorEventIndex)
Ctor.

Parameters:
priorEventIndex - is the number-of-events prior to the current event we are interested in
Method Detail

update

public void update(EventBean[] newData,
                   EventBean[] oldData)
Description copied from interface: ViewUpdatedCollection
Accepts view insert and remove stream.

Specified by:
update in interface ViewUpdatedCollection
Parameters:
newData - is the insert stream events or null if no data
oldData - is the remove stream events or null if no data

update

public void update(EventBean[] newData,
                   EventBean[] oldData,
                   PriorEventBufferChangeCaptureSingle captureSingle)

getRelativeToEvent

public EventBean getRelativeToEvent(EventBean theEvent,
                                    int priorToIndex)
Description copied from interface: RelativeAccessByEventNIndex
Returns the prior event to the given event counting back the number of events as supplied by index.

Specified by:
getRelativeToEvent in interface RelativeAccessByEventNIndex
Parameters:
theEvent - is the event to count back from
priorToIndex - is the number of events to go back
Returns:
event

getRelativeToEnd

public EventBean getRelativeToEnd(EventBean theEvent,
                                  int index)
Specified by:
getRelativeToEnd in interface RelativeAccessByEventNIndex

getWindowToEvent

public java.util.Iterator<EventBean> getWindowToEvent(java.lang.Object evalEvent)
Specified by:
getWindowToEvent in interface RelativeAccessByEventNIndex

getWindowToEventCount

public int getWindowToEventCount(EventBean evalEvent)
Specified by:
getWindowToEventCount in interface RelativeAccessByEventNIndex

getWindowToEventCollReadOnly

public java.util.Collection<EventBean> getWindowToEventCollReadOnly(java.lang.Object evalEvent)
Specified by:
getWindowToEventCollReadOnly in interface RelativeAccessByEventNIndex

getPriorEventMap

public java.util.Map<EventBean,EventBean> getPriorEventMap()

getNewEvents

public RollingEventBuffer getNewEvents()

destroy

public void destroy()
Description copied from interface: ViewUpdatedCollection
De-allocate resources held by the collection.

Specified by:
destroy in interface ViewUpdatedCollection

getNumEventsInsertBuf

public int getNumEventsInsertBuf()
Specified by:
getNumEventsInsertBuf in interface ViewUpdatedCollection

© 2006-2015 EsperTech Inc.
All rights reserved.
Visit us at espertech.com