|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.relopt.RelOptRule org.eigenbase.rel.rules.RemoveDistinctAggregateRule
public final class RemoveDistinctAggregateRule
Rule to remove distinct aggregates from a AggregateRel
.
Field Summary | |
---|---|
static RemoveDistinctAggregateRule |
instance
The singleton. |
Fields inherited from class org.eigenbase.relopt.RelOptRule |
---|
ANY, description, operands |
Constructor Summary | |
---|---|
private |
RemoveDistinctAggregateRule()
|
Method Summary | |
---|---|
private RelNode |
convertMonopole(AggregateRel aggregate,
List<Integer> argList)
Converts an aggregrate relational expression which contains just one distinct aggregate function (or perhaps several over the same arguments) and no non-distinct aggregate functions. |
private static AggregateRel |
createSelectDistinct(AggregateRel aggregate,
List<Integer> argList,
Map<Integer,Integer> sourceOf)
Given an AggregateRel and the ordinals of the arguments to a
particular call to an aggregate function, creates a 'select distinct'
relational expression which projects the group columns and those
arguments but nothing else. |
private RelNode |
doRewrite(AggregateRel aggregate,
RelNode left,
List<Integer> argList,
RexInputRef[] refs)
Converts all distinct aggregate calls to a given set of arguments. |
private static boolean |
equals(int[] args,
List<Integer> argList)
Returns whether an integer array has the same content as an integer list. |
void |
onMatch(RelOptRuleCall call)
Receives notification about a rule match. |
private static void |
rewriteAggCalls(List<AggregateCall> newAggCalls,
List<Integer> argList,
Map<Integer,Integer> sourceOf)
|
Methods inherited from class org.eigenbase.relopt.RelOptRule |
---|
convert, equals, equals, getOperand, getOperands, getOutConvention, getOutTrait, hashCode, matches, mergeTraitsAndConvert, mergeTraitsAndConvert, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final RemoveDistinctAggregateRule instance
Constructor Detail |
---|
private RemoveDistinctAggregateRule()
Method Detail |
---|
public void onMatch(RelOptRuleCall call)
RelOptRule
call.rels
holds the set of relational
expressions which match the operands to the rule;
call.rels[0]
is the root expression.
Typically a rule would check that the nodes are valid matches, creates
a new expression, then calls back RelOptRuleCall.transformTo(org.eigenbase.rel.RelNode)
to
register the expression.
onMatch
in class RelOptRule
call
- Rule callRelOptRule.matches(RelOptRuleCall)
private RelNode convertMonopole(AggregateRel aggregate, List<Integer> argList)
private RelNode doRewrite(AggregateRel aggregate, RelNode left, List<Integer> argList, RexInputRef[] refs)
This method is called several times, one for each set of arguments. Each time it is called, it generates a JOIN to a new SELECT DISTINCT relational expression, and modifies the set of top-level calls.
aggregate
- Original aggregateleft
- Child relational expression (either the original aggregate,
the output from the previous call to this method, or null in the case
where we're converting the first distinct aggregate in a query with no
non-distinct aggregates)argList
- Arguments to the distinct aggregate functionrefs
- Array of expressions which will be the projected by the
result of this rule. Those relating to this arg list will be modified
private static void rewriteAggCalls(List<AggregateCall> newAggCalls, List<Integer> argList, Map<Integer,Integer> sourceOf)
private static AggregateRel createSelectDistinct(AggregateRel aggregate, List<Integer> argList, Map<Integer,Integer> sourceOf)
AggregateRel
and the ordinals of the arguments to a
particular call to an aggregate function, creates a 'select distinct'
relational expression which projects the group columns and those
arguments but nothing else.
For example, given
and the arglistselect f0, count(distinct f1), count(distinct f2) from t group by f0
{2}returns
'select distinct f0, f2 from t
The sourceOf
map is populated with the source of each
column; in this case sourceOf.get(0) = 0, and sourceOf.get(1) = 2.
aggregate
- Aggregate relational expressionargList
- Ordinals of columns to distinctifysourceOf
- Out paramer, is populated with a map of where each output
field came from
private static boolean equals(int[] args, List<Integer> argList)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |