org.eigenbase.oj.rex
Class OJRexImplementorTableImpl.OJBasicAggImplementor

java.lang.Object
  extended by org.eigenbase.oj.rex.OJRexImplementorTableImpl.OJBasicAggImplementor
All Implemented Interfaces:
OJAggImplementor
Direct Known Subclasses:
OJRexImplementorTableImpl.OJCountAggImplementor, OJRexImplementorTableImpl.OJMinMaxAggImplementor, OJRexImplementorTableImpl.OJSumAggImplementor
Enclosing class:
OJRexImplementorTableImpl

public abstract static class OJRexImplementorTableImpl.OJBasicAggImplementor
extends Object
implements OJAggImplementor


Constructor Summary
OJRexImplementorTableImpl.OJBasicAggImplementor()
           
 
Method Summary
 boolean canMerge()
          Returns whether this aggregation can merge together two accumulators.
 void implementMerge(JavaRelImplementor implementor, RelNode rel, Expression accumulator, Expression otherAccumulator)
          Generates (into the current statement list, gleaned by calling implementor's JavaRelImplementor.getStatementList() method) code to merge two accumulators.
 Expression implementStartAndNext(JavaRelImplementor implementor, JavaRel rel, AggregateCall call)
          This is a default implementation of OJAggImplementor.implementStartAndNext(org.eigenbase.oj.rel.JavaRelImplementor, org.eigenbase.oj.rel.JavaRel, org.eigenbase.rel.AggregateCall); particular derived classes may do better.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eigenbase.oj.rex.OJAggImplementor
implementNext, implementResult, implementStart
 

Constructor Detail

OJRexImplementorTableImpl.OJBasicAggImplementor

public OJRexImplementorTableImpl.OJBasicAggImplementor()
Method Detail

canMerge

public boolean canMerge()
Description copied from interface: OJAggImplementor
Returns whether this aggregation can merge together two accumulators.

For example, COUNT can (you just add the accumulators); AVG and MEDIAN cannot.

Specified by:
canMerge in interface OJAggImplementor
Returns:
whether this aggregation can merge together two accumulators

implementMerge

public void implementMerge(JavaRelImplementor implementor,
                           RelNode rel,
                           Expression accumulator,
                           Expression otherAccumulator)
Description copied from interface: OJAggImplementor
Generates (into the current statement list, gleaned by calling implementor's JavaRelImplementor.getStatementList() method) code to merge two accumulators. For sum(x), this looks like ((saffron.runtime.Holder.int_Holder) accumulator).value += ((saffron.runtime.Holder.int_Holder) other).value.

The method is only called if OJAggImplementor.canMerge() returns true.

Specified by:
implementMerge in interface OJAggImplementor
Parameters:
implementor - a callback object which knows how to generate things
rel - the relational expression which is generating this code
accumulator - the expression which holds the total
otherAccumulator - accumulator to merge in

implementStartAndNext

public Expression implementStartAndNext(JavaRelImplementor implementor,
                                        JavaRel rel,
                                        AggregateCall call)
This is a default implementation of OJAggImplementor.implementStartAndNext(org.eigenbase.oj.rel.JavaRelImplementor, org.eigenbase.oj.rel.JavaRel, org.eigenbase.rel.AggregateCall); particular derived classes may do better.

Specified by:
implementStartAndNext in interface OJAggImplementor