public class WindowFunction extends DataAnalysisOperation
over, overOrderBySort, select, STAGE_GROUP, STAGE_RESET, STAGE_WINDOWMAP_IN_AGGREGATE, MAP_IN_WINDOW, MAP_INITIAL| Constructor and Description |
|---|
WindowFunction(WindowFunctionType type,
Select select,
Expression[] args)
Creates new instance of a window function.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.Object |
createAggregateData()
Create aggregate data object specific to the subclass.
|
protected Value |
getAggregatedValue(Session session,
java.lang.Object aggregateData)
Returns aggregated value.
|
int |
getCost()
Estimate the cost to process the expression.
|
WindowFunctionType |
getFunctionType()
Returns the type of this function.
|
static int |
getMaxArgumentCount(WindowFunctionType type)
Returns maximal number of arguments for the specified type.
|
static int |
getMinArgumentCount(WindowFunctionType type)
Returns minimal number of arguments for the specified type.
|
protected int |
getNumExpressions()
Returns the number of expressions, excluding OVER clause.
|
protected void |
getOrderedResultLoop(Session session,
java.util.HashMap<java.lang.Integer,Value> result,
java.util.ArrayList<Value[]> ordered,
int rowIdColumn)
Returns result of this window function or window aggregate.
|
java.lang.StringBuilder |
getSQL(java.lang.StringBuilder builder)
Appends the SQL statement of this expression to the specified builder.
|
TypeInfo |
getType()
Returns the data type.
|
boolean |
isAggregate()
Checks whether this expression is an aggregate function.
|
void |
mapColumnsAnalysis(ColumnResolver resolver,
int level,
int innerState)
Map the columns of the resolver to expression columns.
|
Expression |
optimize(Session session)
Try to optimize the expression.
|
protected void |
rememberExpressions(Session session,
Value[] array)
Stores current values of expressions into the specified array.
|
void |
setEvaluatable(TableFilter tableFilter,
boolean b)
Tell the expression columns whether the table filter can return values
now.
|
void |
setFromLast(boolean fromLast)
Sets FROM FIRST or FROM LAST clause value.
|
void |
setIgnoreNulls(boolean ignoreNulls)
Sets RESPECT NULLS or IGNORE NULLS clause value.
|
protected void |
updateAggregate(Session session,
SelectGroups groupData,
int groupRowId)
Update a row of an aggregate.
|
protected void |
updateGroupAggregates(Session session,
int stage)
Invoked when processing group stage of grouped window queries to update
arguments of this aggregate.
|
appendTailConditions, createOrder, getGroupData, getOverOrderBySort, getValue, getWindowData, isEverything, mapColumns, setOverCondition, updateAggregate, updateOrderedAggregateaddFilterConditions, createIndexConditions, getAlias, getBooleanValue, getColumnName, getExpressionColumns, getExpressionColumns, getExpressionColumns, getNonAliasExpression, getNotIfPossible, getNullable, getSchemaName, getSQL, getSubexpression, getSubexpressionCount, getTableAlias, getTableName, getUnenclosedSQL, isAutoIncrement, isConstant, isGeneratedKey, isValueSet, toString, writeExpressions, writeExpressionspublic WindowFunction(WindowFunctionType type, Select select, Expression[] args)
type - the typeselect - the select statementargs - arguments, or nullpublic static int getMinArgumentCount(WindowFunctionType type)
type - the type of a window functionpublic static int getMaxArgumentCount(WindowFunctionType type)
type - the type of a window functionpublic WindowFunctionType getFunctionType()
public void setFromLast(boolean fromLast)
fromLast - whether FROM LAST clause was specified.public void setIgnoreNulls(boolean ignoreNulls)
ignoreNulls - whether IGNORE NULLS clause was specifiedpublic boolean isAggregate()
DataAnalysisOperationisAggregate in class DataAnalysisOperationprotected void updateAggregate(Session session, SelectGroups groupData, int groupRowId)
DataAnalysisOperationupdateAggregate in class DataAnalysisOperationsession - the database sessiongroupData - data for the aggregate groupgroupRowId - row id of groupprotected void updateGroupAggregates(Session session, int stage)
DataAnalysisOperationupdateGroupAggregates in class DataAnalysisOperationsession - the sessionstage - select stageprotected int getNumExpressions()
DataAnalysisOperationgetNumExpressions in class DataAnalysisOperationprotected void rememberExpressions(Session session, Value[] array)
DataAnalysisOperationrememberExpressions in class DataAnalysisOperationsession - the sessionarray - array to store values of expressionsprotected java.lang.Object createAggregateData()
DataAnalysisOperationcreateAggregateData in class DataAnalysisOperationprotected void getOrderedResultLoop(Session session, java.util.HashMap<java.lang.Integer,Value> result, java.util.ArrayList<Value[]> ordered, int rowIdColumn)
DataAnalysisOperationgetOrderedResultLoop in class DataAnalysisOperationsession - the sessionresult - the map to append result toordered - ordered datarowIdColumn - the index of row id valueprotected Value getAggregatedValue(Session session, java.lang.Object aggregateData)
DataAnalysisOperationgetAggregatedValue in class DataAnalysisOperationsession - the sessionaggregateData - the aggregate datapublic void mapColumnsAnalysis(ColumnResolver resolver, int level, int innerState)
DataAnalysisOperationmapColumnsAnalysis in class DataAnalysisOperationresolver - the column resolverlevel - the subquery nesting levelinnerState - one of the Expression MAP_IN_* valuespublic Expression optimize(Session session)
Expressionoptimize in class DataAnalysisOperationsession - the sessionpublic void setEvaluatable(TableFilter tableFilter, boolean b)
ExpressionsetEvaluatable in class DataAnalysisOperationtableFilter - the table filterb - true if the table filter can return valuepublic TypeInfo getType()
ExpressiongetType in class Expressionpublic java.lang.StringBuilder getSQL(java.lang.StringBuilder builder)
ExpressiongetSQL in class Expressionbuilder - string builderpublic int getCost()
ExpressiongetCost in class Expression