Top Description Fields Constructors Methods
org.apache.derby.impl.sql.compile

pack-priv Class WindowResultSetNode

extends SingleChildResultSetNode
Class Inheritance
Imports
java.util.ArrayList, .Iterator, .List, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.ClassName, org.apache.derby.iapi.services.classfile.VMOpcode, org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.iapi.services.io.FormatableBitSet, org.apache.derby.shared.common.sanity.SanityManager

A WindowResultSetNode represents a result set for a window partitioning on a select. Modeled on the code in GroupByNode.

Field Summary

Modifier and TypeField and Description
pack-priv FromTable
parent

The parent to the WindowResultSetNode.

pack-priv WindowDefinitionNode
pack-priv List<WindowFunctionNode>
Inherited from org.apache.derby.impl.sql.compile.SingleChildResultSetNode:
childResulthasTrulyTheBestAccessPath

Constructor Summary

AccessConstructor and Description
pack-priv
WindowResultSetNode(ResultSetNode
The project restrict result set we want to wrap
bottomPR
,
WindowDefinitionNode
The window definition
windowDef
,
List<WindowFunctionNode>
All window function calls in SELECT's select list and order by list.
windowFuncCalls
,
int
Nesting level
nestingLevel
,
ContextManager
The context manager
cm
)

Constructor for a WindowResultSetNode.

Method Summary

Modifier and TypeMethod and Description
private void
addNewColumns()

Substitute new result columns for window function calls and add the result columns to childResult's list of columns.

private void
addNewPRNode()

Add a new PR node.

private boolean

Returns:

true if an equivalent column reference to cand is already present in uniqueColRefs
colRefAlreadySeen
(List<ValueNode>
list of unique column references
uniqueColRefs
,
ColumnReference
the candidate to check is present in list
cand
)

pack-priv void
generate(ActivationClassBuilder
The ActivationClassBuilder for the class being built
acb
,
MethodBuilder
The method for the generated code to go into
mb
)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.generate.

Do the code generation for this node.

pack-priv final FromTable

Returns:

parent of this node, a PRN, used by SelectNode to retrieve new top result set node after window result set rewrite of result set tree.
getParent
()

public void
printSubNodes(int
The depth of this node in the tree
depth
)

Overrides org.apache.derby.impl.sql.compile.SingleChildResultSetNode.printSubNodes.

QueryTreeNode override

Inherited from org.apache.derby.impl.sql.compile.SingleChildResultSetNode:
acceptChildrenaddNewPredicateadjustForSortEliminationadjustForSortEliminationchangeAccessPathdecrementLevelensurePredicateListflattenableInFromSubqueryforUpdategetChildResultgetFinalCostEstimategetFromTableByNamegetTrulyTheBestAccessPathinitAccessPathsisNotExistsisOneRowResultSetisOrderedOnmodifyAccessPathsoptimizepreprocesspullOptPredicatespushExpressionsreferencesSessionSchemareferencesTargetreflectionNeededForProjectionsetChildResultsetLevelsubqueryReferencesTargetupdateBestPlanMapupdateTargetLockMode

Field Detail

parentback to summary
pack-priv FromTable parent

The parent to the WindowResultSetNode. We generate a ProjectRestrict over the windowing node and parent is set to that node.

wdnback to summary
pack-priv WindowDefinitionNode wdn
windowFuncCallsback to summary
pack-priv List<WindowFunctionNode> windowFuncCalls

Constructor Detail

WindowResultSetNodeback to summary
pack-priv WindowResultSetNode(ResultSetNode bottomPR, WindowDefinitionNode windowDef, List<WindowFunctionNode> windowFuncCalls, int nestingLevel, ContextManager cm) throws StandardException

Constructor for a WindowResultSetNode.

Parameters
bottomPR:ResultSetNode

The project restrict result set we want to wrap

windowDef:WindowDefinitionNode

The window definition

windowFuncCalls:List<WindowFunctionNode>

All window function calls in SELECT's select list and order by list.

nestingLevel:int

Nesting level

cm:ContextManager

The context manager

Annotations
@SuppressWarnings:LeakingThisInConstructor
Exceptions
StandardException:
Thrown on error

Method Detail

addNewColumnsback to summary
private void addNewColumns() throws StandardException

Substitute new result columns for window function calls and add the result columns to childResult's list of columns.

Exceptions
StandardException:
standard error policy
addNewPRNodeback to summary
private void addNewPRNode() throws StandardException

Add a new PR node. Put the new PR under any sort.

Exceptions
StandardException:
standard error policy
colRefAlreadySeenback to summary
private boolean colRefAlreadySeen(List<ValueNode> uniqueColRefs, ColumnReference cand) throws StandardException
Parameters
uniqueColRefs:List<ValueNode>

list of unique column references

cand:ColumnReference

the candidate to check is present in list

Returns:boolean

true if an equivalent column reference to cand is already present in uniqueColRefs

Exceptions
StandardException:
standard error policy
generateback to summary
pack-priv void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.generate.

Doc from org.apache.derby.impl.sql.compile.QueryTreeNode.generate.

Do the code generation for this node. This is a place-holder method - it should be over-ridden in the sub-classes.

Parameters
acb:ActivationClassBuilder

The ActivationClassBuilder for the class being built

mb:MethodBuilder

The method for the generated code to go into

Annotations
@Override
Exceptions
StandardException:
Thrown on error
getParentback to summary
pack-priv final FromTable getParent()
Returns:FromTable

parent of this node, a PRN, used by SelectNode to retrieve new top result set node after window result set rewrite of result set tree.

printSubNodesback to summary
public void printSubNodes(int depth)

Overrides org.apache.derby.impl.sql.compile.SingleChildResultSetNode.printSubNodes.

QueryTreeNode override

Parameters
depth:int

Doc from org.apache.derby.impl.sql.compile.SingleChildResultSetNode.printSubNodes.

The depth of this node in the tree

Annotations
@Override
See Also
QueryTreeNode#printSubNodes