public class Aggregate extends AbstractAggregate implements ExpressionWithFlags
args, distinct, filterCondition, type
over, overOrderBySort, select, STAGE_GROUP, STAGE_RESET, STAGE_WINDOW
AUTO_PARENTHESES, MAP_IN_AGGREGATE, MAP_IN_WINDOW, MAP_INITIAL, WITH_PARENTHESES, WITHOUT_PARENTHESES
ADD_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, getFilterCondition, getOrderedResultLoop, getSubexpression, getSubexpressionCount, getType, isAggregate, setFilterCondition, updateAggregate
createOrder, getGroupData, getOverCondition, getOverOrderBySort, getWindowData, mapColumns, setOverCondition, updateAggregate, updateOrderedAggregate
addFilterConditions, 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, writeExpressions
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getTraceSQL
public 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)
ExpressionWithFlags
setFlags
in interface ExpressionWithFlags
flags
- the flags to setpublic int getFlags()
ExpressionWithFlags
getFlags
in interface ExpressionWithFlags
protected void updateAggregate(SessionLocal session, java.lang.Object aggregateData)
AbstractAggregate
updateAggregate
in class AbstractAggregate
session
- the sessionaggregateData
- aggregate dataprotected void updateGroupAggregates(SessionLocal session, int stage)
DataAnalysisOperation
updateGroupAggregates
in class AbstractAggregate
session
- the sessionstage
- select stageprotected int getNumExpressions()
DataAnalysisOperation
getNumExpressions
in class DataAnalysisOperation
protected void rememberExpressions(SessionLocal session, Value[] array)
DataAnalysisOperation
rememberExpressions
in class DataAnalysisOperation
session
- the sessionarray
- array to store values of expressionsprotected void updateFromExpressions(SessionLocal session, java.lang.Object aggregateData, Value[] array)
AbstractAggregate
updateFromExpressions
in class AbstractAggregate
session
- the sessionaggregateData
- aggregate dataarray
- values of expressionsprotected java.lang.Object createAggregateData()
DataAnalysisOperation
createAggregateData
in class DataAnalysisOperation
public Value getValue(SessionLocal session)
Expression
getValue
in class DataAnalysisOperation
session
- the sessionpublic Value getAggregatedValue(SessionLocal session, java.lang.Object aggregateData)
DataAnalysisOperation
getAggregatedValue
in class DataAnalysisOperation
session
- the sessionaggregateData
- the aggregate datapublic void mapColumnsAnalysis(ColumnResolver resolver, int level, int innerState)
DataAnalysisOperation
mapColumnsAnalysis
in class AbstractAggregate
resolver
- the column resolverlevel
- the subquery nesting levelinnerState
- one of the Expression MAP_IN_* valuespublic Expression optimize(SessionLocal session)
Expression
optimize
in class AbstractAggregate
session
- the sessionpublic void setEvaluatable(TableFilter tableFilter, boolean b)
Expression
setEvaluatable
in class AbstractAggregate
tableFilter
- the table filterb
- true if the table filter can return valuepublic java.lang.StringBuilder getUnenclosedSQL(java.lang.StringBuilder builder, int sqlFlags)
Expression
getUnenclosedSQL
in class Expression
builder
- string buildersqlFlags
- formatting flagspublic boolean isEverything(ExpressionVisitor visitor)
Expression
isEverything
in class DataAnalysisOperation
visitor
- the visitorpublic int getCost()
Expression
getCost
in class Expression
public Select getSelect()
public boolean isDistinct()