Class GroupByNode.ExpressionSorter

java.lang.Object
org.apache.derby.impl.sql.compile.GroupByNode.ExpressionSorter
All Implemented Interfaces:
Comparator<SubstituteExpressionVisitor>
Enclosing class:
GroupByNode

private static class GroupByNode.ExpressionSorter extends Object implements Comparator<SubstituteExpressionVisitor>
Comparator class for GROUP BY expression substitution. This class enables the sorting of a collection of SubstituteExpressionVisitor instances. We sort the visitors during the tree manipulation processing in order to process expressions of higher complexity prior to expressions of lower complexity. Processing the expressions in this order ensures that we choose the best match for an expression, and thus avoids problems where we substitute a sub-expression instead of the full expression. For example, if the statement is: ... GROUP BY a+b, a, a*(a+b), a+b+c we'll process those expressions in the order: a*(a+b), a+b+c, a+b, then a.