net.esper.eql.expression
Class OrderByProcessorSimple

java.lang.Object
  extended by net.esper.eql.expression.OrderByProcessorSimple
All Implemented Interfaces:
OrderByProcessor

public class OrderByProcessorSimple
extends java.lang.Object
implements OrderByProcessor

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


Constructor Summary
OrderByProcessorSimple(java.util.List<Pair<ExprNode,java.lang.Boolean>> orderByList, java.util.List<ExprNode> groupByNodes, boolean needsGroupByKeys, AggregationService aggregationService)
          Ctor.
 
Method Summary
protected static int compareValues(java.lang.Object valueOne, java.lang.Object valueTwo, boolean descending)
          Compares values for sorting.
 EventBean[] sort(EventBean[] outgoingEvents, EventBean[][] generatingEvents)
          Sort the output events.
 EventBean[] sort(EventBean[] outgoingEvents, EventBean[][] generatingEvents, MultiKey[] groupByKeys)
          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(java.util.List<Pair<ExprNode,java.lang.Boolean>> orderByList,
                              java.util.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)
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)
Returns:
an array containing the output events in sorted order

sort

public EventBean[] sort(EventBean[] outgoingEvents,
                        EventBean[][] generatingEvents,
                        MultiKey[] groupByKeys)
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
Returns:
an array containing the output events in sorted order

compareValues

protected static int compareValues(java.lang.Object valueOne,
                                   java.lang.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