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

java.lang.Object
  extended by com.espertech.esper.epl.join.table.PropertyIndexedEventTable
All Implemented Interfaces:
EventTable
Direct Known Subclasses:
PropertyIndTableCoerceAdd

public class PropertyIndexedEventTable
extends 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  EventPropertyGetter[] propertyGetters
          Getters for properties.
protected  Map<MultiKeyUntyped,Set<EventBean>> propertyIndex
          Index table.
 
Constructor Summary
PropertyIndexedEventTable(int streamNum, EventType eventType, String[] propertyNames)
          Ctor.
 
Method Summary
 void add(EventBean[] events)
          Add an array of events.
 void clear()
          Clear out index.
protected  MultiKeyUntyped getMultiKey(EventBean event)
          Determine multikey for index access.
 boolean isEmpty()
          Returns true if the index is empty, or false if not
 Iterator<EventBean> iterator()
          Returns an iterator over events in the table.
 Set<EventBean> lookup(Object[] keys)
          Returns the set of events that have the same property value as the given event.
 void remove(EventBean[] events)
          Remove events.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

propertyGetters

protected final EventPropertyGetter[] propertyGetters
Getters for properties.


propertyIndex

protected final Map<MultiKeyUntyped,Set<EventBean>> propertyIndex
Index table.

Constructor Detail

PropertyIndexedEventTable

public PropertyIndexedEventTable(int streamNum,
                                 EventType eventType,
                                 String[] propertyNames)
Ctor.

Parameters:
streamNum - - the stream number that is indexed
eventType - - types of events indexed
propertyNames - - property names to use for indexing
Method Detail

getMultiKey

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

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

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:
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:
IllegalArgumentException - when the event could not be removed as its not in the index

lookup

public Set<EventBean> lookup(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)

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 Iterator<EventBean> iterator()
Description copied from interface: EventTable
Returns an iterator over events in the table.

Specified by:
iterator in interface EventTable
Returns:
table iterator

clear

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

Specified by:
clear in interface EventTable

toString

public String toString()
Overrides:
toString in class Object

© 2007 EsperTech Inc.
All rights reserved.
Visit us at espertech.com