org.eigenbase.rel
Class AggregateRelBase

java.lang.Object
  extended by org.eigenbase.rel.AbstractRelNode
      extended by org.eigenbase.rel.SingleRel
          extended by org.eigenbase.rel.AggregateRelBase
All Implemented Interfaces:
Cloneable, RelNode
Direct Known Subclasses:
AggregateRel, FennelAggRel, LhxAggRel

public abstract class AggregateRelBase
extends SingleRel

AggregateRelBase is an abstract base class for implementations of AggregateRel.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/rel/AggregateRelBase.java#21 $
Author:
John V. Sichi

Nested Class Summary
static class AggregateRelBase.AggCallBinding
          Implementation of the SqlOperatorBinding interface for an aggregate call applied to a set of operands in the context of a AggregateRel.
 
Field Summary
protected  List<AggregateCall> aggCalls
           
protected  int groupCount
           
 
Fields inherited from class org.eigenbase.rel.AbstractRelNode
digest, id, nextId, rowType, traits
 
Fields inherited from interface org.eigenbase.rel.RelNode
emptyArray
 
Constructor Summary
protected AggregateRelBase(RelOptCluster cluster, RelTraitSet traits, RelNode child, int groupCount, List<AggregateCall> aggCalls)
          Creates an AggregateRelBase.
 
Method Summary
 RelOptCost computeSelfCost(RelOptPlanner planner)
          Returns the cost of this plan (not including children).
 boolean containsDistinctCall()
          Returns whether any of the aggregates are DISTINCT.
protected  RelDataType deriveRowType()
           
 void explain(RelOptPlanWriter pw)
           
 List<AggregateCall> getAggCallList()
          Returns a list of calls to aggregate functions.
 int getGroupCount()
          Returns the number of grouping fields.
 double getRows()
          Returns an estimate of the number of rows this relational expression will return.
 boolean isDistinct()
          Returns whether the same value will not come out twice.
private  boolean typeMatchesInferred(AggregateCall aggCall, boolean fail)
          Returns whether the inferred type of an AggregateCall matches the type it was given when it was created.
 
Methods inherited from class org.eigenbase.rel.SingleRel
childrenAccept, getChild, getInputs, replaceInput
 
Methods inherited from class org.eigenbase.rel.AbstractRelNode
clone, cloneTraits, collectVariablesSet, collectVariablesUsed, computeDigest, getChildExps, getCluster, getCollationList, getConvention, getCorrelVariable, getDescription, getDigest, getExpectedInputRowType, getId, getInput, getOrCreateCorrelVariable, getQuery, getRelTypeName, getRowType, getTable, getTraits, getVariablesStopped, inheritTraitsFrom, isAccessTo, isValid, onRegister, recomputeDigest, register, registerCorrelVariable, setCorrelVariable, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

aggCalls

protected List<AggregateCall> aggCalls

groupCount

protected int groupCount
Constructor Detail

AggregateRelBase

protected AggregateRelBase(RelOptCluster cluster,
                           RelTraitSet traits,
                           RelNode child,
                           int groupCount,
                           List<AggregateCall> aggCalls)
Creates an AggregateRelBase.

Parameters:
cluster - Cluster
traits - Traits
child - Child
groupCount - Size of grouping key
aggCalls - Collection of calls to aggregate functions
Method Detail

isDistinct

public boolean isDistinct()
Description copied from interface: RelNode
Returns whether the same value will not come out twice. Default value is false, derived classes should override.

Specified by:
isDistinct in interface RelNode
Overrides:
isDistinct in class AbstractRelNode

getAggCallList

public List<AggregateCall> getAggCallList()
Returns a list of calls to aggregate functions.

Returns:
list of calls to aggregate functions

getGroupCount

public int getGroupCount()
Returns the number of grouping fields. These fields are the leading fields in both the input and output records.

Returns:
number of grouping fields

explain

public void explain(RelOptPlanWriter pw)
Specified by:
explain in interface RelNode
Overrides:
explain in class SingleRel

getRows

public double getRows()
Description copied from interface: RelNode
Returns an estimate of the number of rows this relational expression will return.

NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use RelMetadataQuery.getRowCount(org.eigenbase.rel.RelNode), which gives plugins a chance to override the rel's default ideas about row count.

Specified by:
getRows in interface RelNode
Overrides:
getRows in class SingleRel

computeSelfCost

public RelOptCost computeSelfCost(RelOptPlanner planner)
Description copied from interface: RelNode
Returns the cost of this plan (not including children). The base implementation throws an error; derived classes should override.

NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use RelMetadataQuery.getNonCumulativeCost(org.eigenbase.rel.RelNode), which gives plugins a chance to override the rel's default ideas about cost.

Specified by:
computeSelfCost in interface RelNode
Overrides:
computeSelfCost in class AbstractRelNode

deriveRowType

protected RelDataType deriveRowType()
Overrides:
deriveRowType in class SingleRel

typeMatchesInferred

private boolean typeMatchesInferred(AggregateCall aggCall,
                                    boolean fail)
Returns whether the inferred type of an AggregateCall matches the type it was given when it was created.

Parameters:
aggCall - Aggregate call
fail - Whether to fail if the types do not match
Returns:
Whether the inferred and declared types match

containsDistinctCall

public boolean containsDistinctCall()
Returns whether any of the aggregates are DISTINCT.