net.esper.eql.core
Class OrderByProcessorSimple

java.lang.Object
  extended by net.esper.eql.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<Pair<ExprNode,Boolean>> 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.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrderByProcessorSimple

public OrderByProcessorSimple(List<Pair<ExprNode,Boolean>> 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

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