com.espertech.esper.epl.core
Class OrderByProcessorSimple

java.lang.Object
  extended by com.espertech.esper.epl.core.OrderByProcessorSimple
All Implemented Interfaces:
OrderByProcessor

public class OrderByProcessorSimple
extends Object
implements OrderByProcessor

An order-by processor that sorts events according to the expressions in the order_by clause.


Constructor Summary
OrderByProcessorSimple(List<OrderByItem> orderByList, List<ExprNode> groupByNodes, boolean needsGroupByKeys, AggregationService aggregationService)
          Ctor.
 
Method Summary
protected static int compareValues(Object valueOne, Object valueTwo, boolean descending)
          Compares values for sorting.
 MultiKeyUntyped getSortKey(EventBean[] eventsPerStream, boolean isNewData)
          Returns the sort key for a given row.
 MultiKeyUntyped[] getSortKeyPerRow(EventBean[] generatingEvents, boolean isNewData)
          Returns the sort key for a each row where a row is a single event (no join, single stream).
 EventBean[] sort(EventBean[] outgoingEvents, EventBean[][] generatingEvents, boolean isNewData)
          Sort the output events.
 EventBean[] sort(EventBean[] outgoingEvents, EventBean[][] generatingEvents, MultiKeyUntyped[] groupByKeys, boolean isNewData)
          Sort the output events, using the provided group-by keys for evaluating grouped aggregation functions, and avoiding the cost of recomputing the keys.
 EventBean[] sort(EventBean[] outgoingEvents, MultiKeyUntyped[] orderKeys)
          Sort a given array of outgoing events using the sort keys returning a sorted outgoing event array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrderByProcessorSimple

public OrderByProcessorSimple(List<OrderByItem> orderByList,
                              List<ExprNode> groupByNodes,
                              boolean needsGroupByKeys,
                              AggregationService aggregationService)
Ctor.

Parameters:
orderByList - - the nodes that generate the keys to sort events on
groupByNodes - - generate the keys for determining aggregation groups
needsGroupByKeys - - indicates whether this processor needs to have individual group by keys to evaluate the sort condition successfully
aggregationService - - used to evaluate aggregate functions in the group-by and sort-by clauses
Method Detail

getSortKey

public MultiKeyUntyped getSortKey(EventBean[] eventsPerStream,
                                  boolean isNewData)
Description copied from interface: OrderByProcessor
Returns the sort key for a given row.

Specified by:
getSortKey in interface OrderByProcessor
Parameters:
eventsPerStream - is the row consisting of one event per stream
isNewData - is true for new data
Returns:
sort key

getSortKeyPerRow

public MultiKeyUntyped[] getSortKeyPerRow(EventBean[] generatingEvents,
                                          boolean isNewData)
Description copied from interface: OrderByProcessor
Returns the sort key for a each row where a row is a single event (no join, single stream).

Specified by:
getSortKeyPerRow in interface OrderByProcessor
Parameters:
generatingEvents - is the rows consisting of one event per row
isNewData - is true for new data
Returns:
sort key for each row

sort

public EventBean[] sort(EventBean[] outgoingEvents,
                        EventBean[][] generatingEvents,
                        boolean isNewData)
Description copied from interface: OrderByProcessor
Sort the output events. If the order-by processor needs group-by keys to evaluate the expressions in the order-by clause, these will be computed from the generating events.

Specified by:
sort in interface OrderByProcessor
Parameters:
outgoingEvents - - the events to be sorted
generatingEvents - - the events that generated the output events (each event has a corresponding array of generating events per different event streams)
isNewData - - indicates whether we are dealing with new data (istream) or old data (rstream)
Returns:
an array containing the output events in sorted order

sort

public EventBean[] sort(EventBean[] outgoingEvents,
                        EventBean[][] generatingEvents,
                        MultiKeyUntyped[] groupByKeys,
                        boolean isNewData)
Description copied from interface: OrderByProcessor
Sort the output events, using the provided group-by keys for evaluating grouped aggregation functions, and avoiding the cost of recomputing the keys.

Specified by:
sort in interface OrderByProcessor
Parameters:
outgoingEvents - - the events to sort
generatingEvents - - the events that generated the output events (each event has a corresponding array of generating events per different event streams)
groupByKeys - - the keys to use for determining the group-by group of output events
isNewData - - indicates whether we are dealing with new data (istream) or old data (rstream)
Returns:
an array containing the output events in sorted order

compareValues

protected static int compareValues(Object valueOne,
                                   Object valueTwo,
                                   boolean descending)
Compares values for sorting.

Parameters:
valueOne - -first value to compare, can be null
valueTwo - -second value to compare, can be null
descending - - true if ascending, false if descending
Returns:
0 if equal, -1 if smaller, +1 if larger

sort

public EventBean[] sort(EventBean[] outgoingEvents,
                        MultiKeyUntyped[] orderKeys)
Description copied from interface: OrderByProcessor
Sort a given array of outgoing events using the sort keys returning a sorted outgoing event array.

Specified by:
sort in interface OrderByProcessor
Parameters:
outgoingEvents - is the events to sort
orderKeys - is the keys to sort by
Returns:
sorted events

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