net.sf.saffron.oj.rel
Class JavaAggregateRel

java.lang.Object
  |
  +--net.sf.saffron.rel.SaffronRel
        |
        +--net.sf.saffron.rel.SingleRel
              |
              +--net.sf.saffron.rel.AggregateRel
                    |
                    +--net.sf.saffron.oj.rel.JavaAggregateRel

public class JavaAggregateRel
extends AggregateRel

JavaAggregateRel implements the AggregateRel relational operator by generating code. The code looks like this:

HashMap h = new HashMap();
 for each child
   HashableArray groups = new HashableArray(
     new Object[] {
   	 child.field4,
   	 child.field2});
   Object[] aggs = h.get(groups);
   if (aggs == null) {
     aggs = new Object[<>];
     aggs[0] = agg start code;
     aggs[1] = agg start code;
     h.put(groups, aggs);
   }
   agg inc code {aggs[0], childRow}
   agg inc code {aggs[1], childRow}
 end for
 Iterator keys = h.keys();
 while (keys.hasNext()) {
 	 T row = new T();
 	 HashableArray groups = (HashableArray) keys.next();
 	 row.c0 = groups[0];
 	 row.c1 = groups[1];
 	 Object[] aggs = h.get(groups);
 	 row.c2 = agg result code {aggs[0]}
 	 row.c3 = agg result code {aggs[1]}
   emit row to parent
 }
Simplifications:


Nested Class Summary
 
Nested classes inherited from class net.sf.saffron.rel.AggregateRel
AggregateRel.Call
 
Field Summary
(package private)  Variable var_h
           
 
Fields inherited from class net.sf.saffron.rel.AggregateRel
aggCalls, groupCount
 
Fields inherited from class net.sf.saffron.rel.SingleRel
child
 
Fields inherited from class net.sf.saffron.rel.SaffronRel
cluster, digest, id, rowType
 
Constructor Summary
JavaAggregateRel(VolcanoCluster cluster, SaffronRel child, int groupCount, AggregateRel.Call[] aggCalls)
           
 
Method Summary
 Object clone()
           
 PlanCost computeSelfCost(SaffronPlanner planner)
          Returns the cost of this plan (not including children).
 CallingConvention getConvention()
          Returns a value from CallingConvention.
 Object implement(RelImplementor implementor, int ordinal)
          Create a plan for this expression according to a calling convention.
 
Methods inherited from class net.sf.saffron.rel.AggregateRel
deriveRowType, getAggCalls, getGroupCount
 
Methods inherited from class net.sf.saffron.rel.SingleRel
childrenAccept, explain, getInputs, getRows, replaceInput
 
Methods inherited from class net.sf.saffron.rel.SaffronRel
computeDigest, getChildExps, getCluster, getCorrelVariable, getId, getInput, getOrCreateCorrelVariable, getQualifier, getQuery, getRelTypeName, getRowType, getTable, getVariablesStopped, implementFieldAccess, isAccessTo, isDistinct, onRegister, recomputeDigest, register, registerCorrelVariable, setCorrelVariable, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

var_h

Variable var_h
Constructor Detail

JavaAggregateRel

public JavaAggregateRel(VolcanoCluster cluster,
                        SaffronRel child,
                        int groupCount,
                        AggregateRel.Call[] aggCalls)
Method Detail

getConvention

public CallingConvention getConvention()
Description copied from class: SaffronRel
Returns a value from CallingConvention.

Overrides:
getConvention in class SaffronRel

clone

public Object clone()
Overrides:
clone in class AggregateRel

computeSelfCost

public PlanCost computeSelfCost(SaffronPlanner planner)
Description copied from class: SaffronRel
Returns the cost of this plan (not including children). The base implementation throws an error; derived classes should override.

Overrides:
computeSelfCost in class AggregateRel

implement

public Object implement(RelImplementor implementor,
                        int ordinal)
Description copied from class: SaffronRel
Create a plan for this expression according to a calling convention.

Overrides:
implement in class SaffronRel
Parameters:
implementor - implementor
ordinal - indicates our position in the pre-, in- and postfix walk over the tree; ordinal is -1 when called from the parent, and i when called from the ith child.

SourceForge.net_Logo