com.espertech.esper.epl.join.table
Class PropertyIndexedEventTable

java.lang.Object
  extended by com.espertech.esper.epl.join.table.PropertyIndexedEventTable
All Implemented Interfaces:
EventTable, java.lang.Iterable<EventBean>
Direct Known Subclasses:
PropertyIndexedEventTableCoerceAdd, PropertyIndexedEventTableUnique

public class PropertyIndexedEventTable
extends java.lang.Object
implements EventTable

Index that organizes events by the event property values into hash buckets. Based on a HashMap with MultiKeyUntyped keys that store the property values. Takes a list of property names as parameter. Doesn't care which event type the events have as long as the properties exist. If the same event is added twice, the class throws an exception on add.


Field Summary
protected  EventTableOrganization organization
           
protected  EventPropertyGetter[] propertyGetters
           
protected  java.util.Map<MultiKeyUntyped,java.util.Set<EventBean>> propertyIndex
           
 
Constructor Summary
PropertyIndexedEventTable(EventPropertyGetter[] propertyGetters, EventTableOrganization organization)
           
 
Method Summary
 void add(EventBean theEvent)
          Add event to table.
 void add(EventBean[] events)
          Add an array of events.
 void addRemove(EventBean[] newData, EventBean[] oldData)
          Add and remove events from table.
 void clear()
          Clear out index.
 java.lang.Object getIndex()
          Return the index object itself, or an object-array for multiple index structures.
protected  MultiKeyUntyped getMultiKey(EventBean theEvent)
          Determine multikey for index access.
 java.lang.Integer getNumberOfEvents()
          If the number of events is readily available, an implementation will return that number or it may return null to indicate that the count is not readily available.
 int getNumKeys()
          If the index retains events using some key-based organization this returns the number of keys, and may return null to indicate that either the number of keys is not available or costly to obtain.
 EventTableOrganization getOrganization()
           
 boolean isEmpty()
          Returns true if the index is empty, or false if not
 java.util.Iterator<EventBean> iterator()
          Returns an iterator over events in the table.
 java.util.Set<EventBean> lookup(java.lang.Object[] keys)
          Returns the set of events that have the same property value as the given event.
 void remove(EventBean theEvent)
          Remove event from table.
 void remove(EventBean[] events)
          Remove events.
 java.lang.String toQueryPlan()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

propertyGetters

protected final EventPropertyGetter[] propertyGetters

organization

protected final EventTableOrganization organization

propertyIndex

protected final java.util.Map<MultiKeyUntyped,java.util.Set<EventBean>> propertyIndex
Constructor Detail

PropertyIndexedEventTable

public PropertyIndexedEventTable(EventPropertyGetter[] propertyGetters,
                                 EventTableOrganization organization)
Method Detail

getMultiKey

protected MultiKeyUntyped getMultiKey(EventBean theEvent)
Determine multikey for index access.

Parameters:
theEvent - to get properties from for key
Returns:
multi key

addRemove

public void addRemove(EventBean[] newData,
                      EventBean[] oldData)
Description copied from interface: EventTable
Add and remove events from table.

It is up to the index to decide whether to add first and then remove, or whether to remove and then add.

It is important to note that a given event can be in both the removed and the added events. This means that unique indexes probably need to remove first and then add. Most other non-unique indexes will add first and then remove since the an event can be both in the add and the remove stream.

Specified by:
addRemove in interface EventTable
Parameters:
newData - to add
oldData - to remove

add

public void add(EventBean[] events)
Add an array of events. Same event instance is not added twice. Event properties should be immutable. Allow null passed instead of an empty array.

Specified by:
add in interface EventTable
Parameters:
events - to add
Throws:
java.lang.IllegalArgumentException - if the event was already existed in the index

remove

public void remove(EventBean[] events)
Remove events.

Specified by:
remove in interface EventTable
Parameters:
events - to be removed, can be null instead of an empty array.
Throws:
java.lang.IllegalArgumentException - when the event could not be removed as its not in the index

lookup

public java.util.Set<EventBean> lookup(java.lang.Object[] keys)
Returns the set of events that have the same property value as the given event.

Parameters:
keys - to compare against
Returns:
set of events with property value, or null if none found (never returns zero-sized set)

add

public void add(EventBean theEvent)
Description copied from interface: EventTable
Add event to table.

Specified by:
add in interface EventTable
Parameters:
theEvent - to add

remove

public void remove(EventBean theEvent)
Description copied from interface: EventTable
Remove event from table.

Specified by:
remove in interface EventTable
Parameters:
theEvent - to remove

isEmpty

public boolean isEmpty()
Description copied from interface: EventTable
Returns true if the index is empty, or false if not

Specified by:
isEmpty in interface EventTable
Returns:
true for empty index

iterator

public java.util.Iterator<EventBean> iterator()
Description copied from interface: EventTable
Returns an iterator over events in the table.

Specified by:
iterator in interface EventTable
Specified by:
iterator in interface java.lang.Iterable<EventBean>
Returns:
table iterator

clear

public void clear()
Description copied from interface: EventTable
Clear out index.

Specified by:
clear in interface EventTable

toQueryPlan

public java.lang.String toQueryPlan()
Specified by:
toQueryPlan in interface EventTable

getNumberOfEvents

public java.lang.Integer getNumberOfEvents()
Description copied from interface: EventTable
If the number of events is readily available, an implementation will return that number or it may return null to indicate that the count is not readily available.

Specified by:
getNumberOfEvents in interface EventTable
Returns:
number of events

getNumKeys

public int getNumKeys()
Description copied from interface: EventTable
If the index retains events using some key-based organization this returns the number of keys, and may return null to indicate that either the number of keys is not available or costly to obtain.

The number returned can be an estimate and may not be accurate.

Specified by:
getNumKeys in interface EventTable
Returns:
number of events

getIndex

public java.lang.Object getIndex()
Description copied from interface: EventTable
Return the index object itself, or an object-array for multiple index structures.

May return null if the information is not readily available, i.e. externally maintained index

Specified by:
getIndex in interface EventTable
Returns:
index object

getOrganization

public EventTableOrganization getOrganization()
Specified by:
getOrganization in interface EventTable

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