public abstract class DataAnalysisOperation extends Expression
| Modifier and Type | Field and Description |
|---|---|
protected Window |
over
OVER clause
|
protected SortOrder |
overOrderBySort
Sort order for OVER
|
protected Select |
select
SELECT
|
static int |
STAGE_GROUP
Group stage, used for explicit or implicit GROUP BY operation.
|
static int |
STAGE_RESET
Reset stage.
|
static int |
STAGE_WINDOW
Window processing stage.
|
MAP_IN_AGGREGATE, MAP_IN_WINDOW, MAP_INITIAL| Modifier | Constructor and Description |
|---|---|
protected |
DataAnalysisOperation(Select select) |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.StringBuilder |
appendTailConditions(java.lang.StringBuilder builder,
boolean alwaysQuote)
Used to create SQL for the OVER and FILTER clauses.
|
protected abstract java.lang.Object |
createAggregateData()
Create aggregate data object specific to the subclass.
|
protected static SortOrder |
createOrder(Session session,
java.util.ArrayList<SelectOrderBy> orderBy,
int offset)
Create sort order.
|
protected abstract Value |
getAggregatedValue(Session session,
java.lang.Object aggregateData)
Returns aggregated value.
|
protected java.lang.Object |
getGroupData(SelectGroups groupData,
boolean ifExists)
Get the aggregate group data object from the collector object.
|
protected abstract int |
getNumExpressions()
Returns the number of expressions, excluding OVER clause.
|
protected abstract 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.
|
protected SortOrder |
getOverOrderBySort()
Returns the sort order for OVER clause.
|
Value |
getValue(Session session)
Return the resulting value for the current row.
|
protected java.lang.Object |
getWindowData(Session session,
SelectGroups groupData,
boolean forOrderBy)
Get the aggregate data for a window clause.
|
abstract boolean |
isAggregate()
Checks whether this expression is an aggregate function.
|
boolean |
isEverything(ExpressionVisitor visitor)
Check if this expression and all sub-expressions can fulfill a criteria.
|
void |
mapColumns(ColumnResolver resolver,
int level,
int state)
Map the columns of the resolver to expression columns.
|
protected 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 abstract 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 |
setOverCondition(Window over)
Sets the OVER condition.
|
void |
updateAggregate(Session session,
int stage)
Update an aggregate value.
|
protected abstract 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.
|
protected void |
updateOrderedAggregate(Session session,
SelectGroups groupData,
int groupRowId,
java.util.ArrayList<SelectOrderBy> orderBy)
Update a row of an ordered aggregate.
|
addFilterConditions, createIndexConditions, getAlias, getBooleanValue, getColumnName, getCost, getExpressionColumns, getExpressionColumns, getExpressionColumns, getNonAliasExpression, getNotIfPossible, getNullable, getSchemaName, getSQL, getSQL, getSubexpression, getSubexpressionCount, getTableAlias, getTableName, getType, getUnenclosedSQL, isAutoIncrement, isConstant, isNullConstant, isValueSet, toString, writeExpressions, writeExpressionspublic static final int STAGE_RESET
public static final int STAGE_GROUP
public static final int STAGE_WINDOW
protected final Select select
protected Window over
protected SortOrder overOrderBySort
protected DataAnalysisOperation(Select select)
protected static SortOrder createOrder(Session session, java.util.ArrayList<SelectOrderBy> orderBy, int offset)
session - database sessionorderBy - array of order by expressionsoffset - index offsetpublic void setOverCondition(Window over)
over - OVER conditionpublic abstract boolean isAggregate()
protected SortOrder getOverOrderBySort()
public final void mapColumns(ColumnResolver resolver, int level, int state)
ExpressionmapColumns in class Expressionresolver - the column resolverlevel - the subquery nesting levelstate - current state for nesting checks, initial value is
Expression.MAP_INITIALprotected void mapColumnsAnalysis(ColumnResolver resolver, int level, int innerState)
resolver - the column resolverlevel - the subquery nesting levelinnerState - one of the Expression MAP_IN_* valuespublic Expression optimize(Session session)
Expressionoptimize in class Expressionsession - the sessionpublic void setEvaluatable(TableFilter tableFilter, boolean b)
ExpressionsetEvaluatable in class ExpressiontableFilter - the table filterb - true if the table filter can return valuepublic final void updateAggregate(Session session, int stage)
ExpressionupdateAggregate in class Expressionsession - the sessionstage - select stageprotected abstract void updateAggregate(Session session, SelectGroups groupData, int groupRowId)
session - the database sessiongroupData - data for the aggregate groupgroupRowId - row id of groupprotected void updateGroupAggregates(Session session, int stage)
session - the sessionstage - select stageprotected abstract int getNumExpressions()
protected abstract void rememberExpressions(Session session, Value[] array)
session - the sessionarray - array to store values of expressionsprotected java.lang.Object getWindowData(Session session, SelectGroups groupData, boolean forOrderBy)
session - database sessiongroupData - aggregate group dataforOrderBy - true if this is for ORDER BYprotected java.lang.Object getGroupData(SelectGroups groupData, boolean ifExists)
groupData - the collector objectifExists - if true, return null if object not found, if false, return new
object if nothing foundprotected abstract java.lang.Object createAggregateData()
public boolean isEverything(ExpressionVisitor visitor)
ExpressionisEverything in class Expressionvisitor - the visitorpublic Value getValue(Session session)
ExpressiongetValue in class Expressionsession - the sessionprotected abstract Value getAggregatedValue(Session session, java.lang.Object aggregateData)
session - the sessionaggregateData - the aggregate dataprotected void updateOrderedAggregate(Session session, SelectGroups groupData, int groupRowId, java.util.ArrayList<SelectOrderBy> orderBy)
session - the database sessiongroupData - data for the aggregate groupgroupRowId - row id of grouporderBy - list of order by expressionsprotected abstract void getOrderedResultLoop(Session session, java.util.HashMap<java.lang.Integer,Value> result, java.util.ArrayList<Value[]> ordered, int rowIdColumn)
session - the sessionresult - the map to append result toordered - ordered datarowIdColumn - the index of row id valueprotected java.lang.StringBuilder appendTailConditions(java.lang.StringBuilder builder,
boolean alwaysQuote)
builder - string builderalwaysQuote - quote all identifiers