public class Aggregate extends AbstractAggregate implements ExpressionWithFlags
args, distinct, filterCondition, typeover, overOrderBySort, select, STAGE_GROUP, STAGE_RESET, STAGE_WINDOWAUTO_PARENTHESES, MAP_IN_AGGREGATE, MAP_IN_WINDOW, MAP_INITIAL, WITH_PARENTHESES, WITHOUT_PARENTHESESADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS| Constructor and Description |
|---|
Aggregate(AggregateType aggregateType,
Expression[] args,
Select select,
boolean distinct)
Create a new aggregate object.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.Object |
createAggregateData()
Create aggregate data object specific to the subclass.
|
Value |
getAggregatedValue(SessionLocal session,
java.lang.Object aggregateData)
Returns aggregated value.
|
AggregateType |
getAggregateType()
Returns the type of this aggregate.
|
static AggregateType |
getAggregateType(java.lang.String name)
Get the aggregate type for this name, or -1 if no aggregate has been
found.
|
int |
getCost()
Estimate the cost to process the expression.
|
java.lang.Object |
getExtraArguments()
Returns the additional arguments.
|
int |
getFlags()
Returns the flags.
|
protected int |
getNumExpressions()
Returns the number of expressions, excluding OVER clause.
|
Select |
getSelect()
Returns the select statement.
|
java.lang.StringBuilder |
getUnenclosedSQL(java.lang.StringBuilder builder,
int sqlFlags)
Get the SQL statement of this expression.
|
Value |
getValue(SessionLocal session)
Return the resulting value for the current row.
|
boolean |
isDistinct()
Returns if distinct is used.
|
boolean |
isEverything(ExpressionVisitor visitor)
Check if this expression and all sub-expressions can fulfill a criteria.
|
void |
mapColumnsAnalysis(ColumnResolver resolver,
int level,
int innerState)
Map the columns of the resolver to expression columns.
|
Expression |
optimize(SessionLocal session)
Try to optimize the expression.
|
protected void |
rememberExpressions(SessionLocal 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 |
setExtraArguments(java.lang.Object extraArguments)
Sets the additional arguments.
|
void |
setFlags(int flags)
Set the flags for this expression.
|
void |
setOrderByList(java.util.ArrayList<QueryOrderBy> orderByList)
Set the order for ARRAY_AGG() or GROUP_CONCAT() aggregate.
|
protected void |
updateAggregate(SessionLocal session,
java.lang.Object aggregateData)
Updates an aggregate value.
|
protected void |
updateFromExpressions(SessionLocal session,
java.lang.Object aggregateData,
Value[] array)
Updates the provided aggregate data from the remembered expressions.
|
protected void |
updateGroupAggregates(SessionLocal session,
int stage)
Invoked when processing group stage of grouped window queries to update
arguments of this aggregate.
|
appendTailConditions, getOrderedResultLoop, getSubexpression, getSubexpressionCount, getType, isAggregate, setFilterCondition, updateAggregatecreateOrder, getGroupData, getOverOrderBySort, getWindowData, mapColumns, setOverCondition, updateAggregate, updateOrderedAggregateaddFilterConditions, createIndexConditions, getAlias, getBooleanValue, getColumnName, getColumnNameForView, getEnclosedSQL, getNonAliasExpression, getNotIfPossible, getNullable, getSchemaName, getSQL, getSQL, getSQL, getSQL, getTableAlias, getTableName, getWhenSQL, getWhenValue, isConstant, isIdentity, isNullConstant, isValueSet, isWhenConditionOperand, needParentheses, optimizeCondition, toString, writeExpressions, writeExpressionsclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetTraceSQLpublic Aggregate(AggregateType aggregateType, Expression[] args, Select select, boolean distinct)
aggregateType - the aggregate typeargs - the aggregated expressionsselect - the select statementdistinct - if distinct is usedpublic static AggregateType getAggregateType(java.lang.String name)
name - the aggregate function namepublic void setOrderByList(java.util.ArrayList<QueryOrderBy> orderByList)
orderByList - the order by listpublic AggregateType getAggregateType()
public void setExtraArguments(java.lang.Object extraArguments)
extraArguments - the additional argumentspublic java.lang.Object getExtraArguments()
public void setFlags(int flags)
ExpressionWithFlagssetFlags in interface ExpressionWithFlagsflags - the flags to setpublic int getFlags()
ExpressionWithFlagsgetFlags in interface ExpressionWithFlagsprotected void updateAggregate(SessionLocal session, java.lang.Object aggregateData)
AbstractAggregateupdateAggregate in class AbstractAggregatesession - the sessionaggregateData - aggregate dataprotected void updateGroupAggregates(SessionLocal session, int stage)
DataAnalysisOperationupdateGroupAggregates in class AbstractAggregatesession - the sessionstage - select stageprotected int getNumExpressions()
DataAnalysisOperationgetNumExpressions in class DataAnalysisOperationprotected void rememberExpressions(SessionLocal session, Value[] array)
DataAnalysisOperationrememberExpressions in class DataAnalysisOperationsession - the sessionarray - array to store values of expressionsprotected void updateFromExpressions(SessionLocal session, java.lang.Object aggregateData, Value[] array)
AbstractAggregateupdateFromExpressions in class AbstractAggregatesession - the sessionaggregateData - aggregate dataarray - values of expressionsprotected java.lang.Object createAggregateData()
DataAnalysisOperationcreateAggregateData in class DataAnalysisOperationpublic Value getValue(SessionLocal session)
ExpressiongetValue in class DataAnalysisOperationsession - the sessionpublic Value getAggregatedValue(SessionLocal 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 AbstractAggregateresolver - the column resolverlevel - the subquery nesting levelinnerState - one of the Expression MAP_IN_* valuespublic Expression optimize(SessionLocal session)
Expressionoptimize in class AbstractAggregatesession - the sessionpublic void setEvaluatable(TableFilter tableFilter, boolean b)
ExpressionsetEvaluatable in class AbstractAggregatetableFilter - the table filterb - true if the table filter can return valuepublic java.lang.StringBuilder getUnenclosedSQL(java.lang.StringBuilder builder,
int sqlFlags)
ExpressiongetUnenclosedSQL in class Expressionbuilder - string buildersqlFlags - formatting flagspublic boolean isEverything(ExpressionVisitor visitor)
ExpressionisEverything in class DataAnalysisOperationvisitor - the visitorpublic int getCost()
ExpressiongetCost in class Expressionpublic Select getSelect()
public boolean isDistinct()