| Modifier and Type | Field and Description |
|---|---|
| private int | addedColumnOffset
If this sort key is added to the result column list then it is at result column position 1 + resultColumnList.size() - resultColumnList.getOrderBySelect() + addedColumnOffset If the sort key is already in the result column list then addedColumnOffset < 0. |
| private boolean | |
| private ValueNode | |
| private OrderByList | |
| private boolean | |
| private ResultColumn |
| Access | Constructor and Description |
|---|---|
| pack-priv | OrderByColumn(ValueNode
Expression of this column expression, ContextManager The context manager cm)Constructor. |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | acceptChildren(Visitor
the visitor v)Overrides org. Accept the visitor for all visitable children of this node. |
| pack-priv void | bindOrderByColumn(ResultSetNode
The result set being selected from target, OrderByList OrderByList which contains this column oblist)Bind this column. |
| pack-priv void | clearAddedColumnOffset()
Reset addedColumnOffset to indicate that column is no longer added An added column is one which was artificially added to the result column list due to its presence in the ORDER BY clause, as opposed to having been explicitly selected by the user. |
| pack-priv void | collapseAddedColumnGap(int
offset of the column which has just been removed from list gap)Adjust addedColumnOffset to reflect that a column has been removed This routine is called when a previously-added result column has been removed due to being detected as a duplicate. |
| private boolean | Returns: whether a match found or notresult set target, ColumnReference the CR to be checked crOfExpression)This method checks a ColumnReference of this OrderByColumn against the ColumnReferences of the select clause of the query. |
| pack-priv boolean | constantColumn(PredicateList whereClause)
Is this OrderByColumn constant, according to the given predicate list? |
| private boolean | Returns: boolean: whether any expression match foundResult set target)Checks whether the whole expression (OrderByColumn) itself found in the select clause. |
| pack-priv ValueNode | |
| pack-priv ValueNode | getNonRedundantExpression()
Get the underlying expression, skipping over ResultColumns that are marked redundant. |
| pack-priv ResultColumn | |
| pack-priv boolean | Returns: true if ascending, false if descendingOverrides org. Get the column order. |
| pack-priv boolean | Returns: true if NULLs ordered low, false if NULLs ordered highOverrides org. Get the column NULL ordering. |
| private static boolean | |
| pack-priv void | printSubNodes(int
The depth of this node in the tree depth)Overrides org. Prints the sub-nodes of this object. |
| pack-priv void | pullUpOrderByColumn(ResultSetNode
The result set being selected from target)Pull up this orderby column if it doesn't appear in the resultset |
| pack-priv void | remapColumnReferencesToExpressions()
Remap all the column references under this OrderByColumn to their expressions. |
| pack-priv void | |
| private void | resolveAddedColumn(ResultSetNode target)
Assuming this OrderByColumn was "pulled" into the received target's ResultColumnList (because it wasn't there to begin with), use this.addedColumnOffset to figure out which of the target's result columns is the one corresponding to "this". |
| private ResultColumn | |
| pack-priv void | |
| pack-priv void | |
| public String | Returns: This object as a StringOverrides org. Convert this object to a String. |
| addedColumnOffset | back to summary |
|---|---|
| private int addedColumnOffset If this sort key is added to the result column list then it is at result column position 1 + resultColumnList.size() - resultColumnList.getOrderBySelect() + addedColumnOffset If the sort key is already in the result column list then addedColumnOffset < 0. | |
| ascending | back to summary |
|---|---|
| private boolean ascending | |
| expression | back to summary |
|---|---|
| private ValueNode expression | |
| list | back to summary |
|---|---|
| private OrderByList list | |
| nullsOrderedLow | back to summary |
|---|---|
| private boolean nullsOrderedLow | |
| resultCol | back to summary |
|---|---|
| private ResultColumn resultCol | |
| OrderByColumn | back to summary |
|---|---|
| pack-priv OrderByColumn(ValueNode expression, ContextManager cm) Constructor.
| |
| acceptChildren | back to summary |
|---|---|
| pack-priv void acceptChildren(Visitor v) throws StandardException Overrides org. Accept the visitor for all visitable children of this node.
| |
| bindOrderByColumn | back to summary |
|---|---|
| pack-priv void bindOrderByColumn(ResultSetNode target, OrderByList oblist) throws StandardException Bind this column. During binding, we may discover that this order by column was pulled up into the result column list, but is now a duplicate, because the actual result column was expanded into the result column list when "*" expressions were replaced with the list of the table's columns. In such a situation, we will end up calling back to the OrderByList to adjust the addedColumnOffset values of the columns; the "oblist" parameter exists to allow that callback to be performed.
| |
| clearAddedColumnOffset | back to summary |
|---|---|
| pack-priv void clearAddedColumnOffset() Reset addedColumnOffset to indicate that column is no longer added An added column is one which was artificially added to the result column list due to its presence in the ORDER BY clause, as opposed to having been explicitly selected by the user. Since * is not expanded until after the ORDER BY columns have been pulled up, we may add a column, then later decide it is a duplicate of an explicitly selected column. In that case, this method is called, and it does the following: - resets addedColumnOffset to -1 to indicate this is not an added col - calls back to the OrderByList to adjust any other added cols | |
| collapseAddedColumnGap | back to summary |
|---|---|
| pack-priv void collapseAddedColumnGap(int gap) Adjust addedColumnOffset to reflect that a column has been removed This routine is called when a previously-added result column has been removed due to being detected as a duplicate. If that added column had a lower offset than our column, we decrement our offset to reflect that we have just been moved down one slot in the result column list.
| |
| columnMatchFound | back to summary |
|---|---|
| private boolean columnMatchFound(ResultSetNode target, ColumnReference crOfExpression) throws StandardException This method checks a ColumnReference of this OrderByColumn against the ColumnReferences of the select clause of the query.
| |
| constantColumn | back to summary |
|---|---|
| pack-priv boolean constantColumn(PredicateList whereClause) Is this OrderByColumn constant, according to the given predicate list? A constant column is one where all the column references it uses are compared equal to constants. | |
| expressionMatch | back to summary |
|---|---|
| private boolean expressionMatch(ResultSetNode target) throws StandardException Checks whether the whole expression (OrderByColumn) itself found in the select clause.
| |
| getExpression | back to summary |
|---|---|
| pack-priv ValueNode getExpression() | |
| getNonRedundantExpression | back to summary |
|---|---|
| pack-priv ValueNode getNonRedundantExpression() Get the underlying expression, skipping over ResultColumns that are marked redundant. | |
| getResultColumn | back to summary |
|---|---|
| pack-priv ResultColumn getResultColumn() Get the underlying ResultColumn.
| |
| isAscending | back to summary |
|---|---|
| pack-priv boolean isAscending() Overrides org. Get the column order. Overrides OrderedColumn.isAscending.
| |
| isNullsOrderedLow | back to summary |
|---|---|
| pack-priv boolean isNullsOrderedLow() Overrides org. Get the column NULL ordering. Overrides OrderedColumn.getIsNullsOrderedLow.
| |
| isReferedColByNum | back to summary |
|---|---|
| private static boolean isReferedColByNum(ValueNode expression) throws StandardException | |
| printSubNodes | back to summary |
|---|---|
| pack-priv void printSubNodes(int depth) Overrides org. Prints the sub-nodes of this object. See QueryTreeNode.java for how tree printing is supposed to work.
| |
| pullUpOrderByColumn | back to summary |
|---|---|
| pack-priv void pullUpOrderByColumn(ResultSetNode target) throws StandardException Pull up this orderby column if it doesn't appear in the resultset
| |
| remapColumnReferencesToExpressions | back to summary |
|---|---|
| pack-priv void remapColumnReferencesToExpressions() throws StandardException Remap all the column references under this OrderByColumn to their expressions.
| |
| resetToSourceRC | back to summary |
|---|---|
| pack-priv void resetToSourceRC() Order by columns now point to the PRN above the node of interest. We need them to point to the RCL under that one. This is useful when combining sorts where we need to reorder the sorting columns. | |
| resolveAddedColumn | back to summary |
|---|---|
| private void resolveAddedColumn(ResultSetNode target) Assuming this OrderByColumn was "pulled" into the received target's ResultColumnList (because it wasn't there to begin with), use this.addedColumnOffset to figure out which of the target's result columns is the one corresponding to "this". The desired position is w.r.t. the original, user-specified result column list--which is what "visibleSize()" gives us. I.e. To get this OrderByColumn's position in target's RCL, first subtract out all columns which were "pulled" into the RCL for GROUP BY or ORDER BY, then add "this.addedColumnOffset". As an example, if the query was: select sum(j) as s from t1 group by i, k order by k, sum(k) then we will internally add columns "K" and "SUM(K)" to the RCL for ORDER BY, *AND* we will add a generated column "I" to the RCL for GROUP BY. Thus we end up with four result columns: (1) (2) (3) (4) select sum(j) as s, K, SUM(K), I from t1 ... So when we get here and we want to find out which column "this" corresponds to, we begin by taking the total number of VISIBLE columns, which is 1 (i.e. 4 total columns minus 1 GROUP BY column minus 2 ORDER BY columns). Then we add this.addedColumnOffset in order to find the target column position. Since addedColumnOffset is 0-based, an addedColumnOffset value of "0" means we want the the first ORDER BY column added to target's RCL, "1" means we want the second ORDER BY column added, etc. So if we assume that this.addedColumnOffset is "1" in this example then we add that to the RCL's "visible size". And finally, we add 1 more to account for fact that addedColumnOffset is 0-based while column positions are 1-based. This gives: position = 1 + 1 + 1 = 3 which points to SUM(K) in the RCL. Thus an addedColumnOffset value of "1" resolves to column SUM(K) in target's RCL; similarly, an addedColumnOffset value of "0" resolves to "K". DERBY-3303. | |
| resolveColumnReference | back to summary |
|---|---|
| private ResultColumn resolveColumnReference(ResultSetNode target, ColumnReference cr) throws StandardException | |
| setDescending | back to summary |
|---|---|
| pack-priv void setDescending() Mark the column as descending order | |
| setNullsOrderedLow | back to summary |
|---|---|
| pack-priv void setNullsOrderedLow() Mark the column as ordered NULL values lower than non-NULL values. | |
| toString | back to summary |
|---|---|
| public String toString() Overrides org. Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing. | |