Package org.h2.expression.aggregate
Class JavaAggregate
java.lang.Object
org.h2.expression.Expression
org.h2.expression.analysis.DataAnalysisOperation
org.h2.expression.aggregate.AbstractAggregate
org.h2.expression.aggregate.JavaAggregate
This class wraps a user-defined aggregate.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int[]
private int
private final UserAggregate
private JdbcConnection
Fields inherited from class org.h2.expression.aggregate.AbstractAggregate
args, distinct, filterCondition, type
Fields inherited from class org.h2.expression.analysis.DataAnalysisOperation
over, overOrderBySort, select, STAGE_GROUP, STAGE_RESET, STAGE_WINDOW
Fields inherited from class org.h2.expression.Expression
AUTO_PARENTHESES, MAP_IN_AGGREGATE, MAP_IN_WINDOW, MAP_INITIAL, WITH_PARENTHESES, WITHOUT_PARENTHESES
Fields inherited from interface org.h2.util.HasSQL
ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS
-
Constructor Summary
ConstructorsConstructorDescriptionJavaAggregate
(UserAggregate userAggregate, Expression[] args, Select select, boolean distinct) -
Method Summary
Modifier and TypeMethodDescriptionprotected Object
Create aggregate data object specific to the subclass.getAggregatedValue
(SessionLocal session, Object aggregateData) Returns aggregated value.int
getCost()
Estimate the cost to process the expression.private Aggregate
protected int
Returns the number of expressions, excluding OVER clause.getUnenclosedSQL
(StringBuilder builder, int sqlFlags) Get the SQL statement of this expression.boolean
isEverything
(ExpressionVisitor visitor) Check if this expression and all sub-expressions can fulfill a criteria.optimize
(SessionLocal session) Try to optimize the expression.protected void
rememberExpressions
(SessionLocal session, Value[] array) Stores current values of expressions into the specified array.protected void
updateAggregate
(SessionLocal session, Object aggregateData) Updates an aggregate value.private void
updateData
(SessionLocal session, Object aggregateData, Value[] remembered) protected void
updateFromExpressions
(SessionLocal session, 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.Methods inherited from class org.h2.expression.aggregate.AbstractAggregate
appendTailConditions, getOrderedResultLoop, getSubexpression, getSubexpressionCount, getType, isAggregate, mapColumnsAnalysis, setEvaluatable, setFilterCondition, updateAggregate
Methods inherited from class org.h2.expression.analysis.DataAnalysisOperation
createOrder, getGroupData, getOverOrderBySort, getValue, getWindowData, mapColumns, setOverCondition, updateAggregate, updateOrderedAggregate
Methods inherited from class org.h2.expression.Expression
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
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.h2.util.HasSQL
getTraceSQL
-
Field Details
-
userAggregate
-
argTypes
private int[] argTypes -
dataType
private int dataType -
userConnection
-
-
Constructor Details
-
JavaAggregate
public JavaAggregate(UserAggregate userAggregate, Expression[] args, Select select, boolean distinct)
-
-
Method Details
-
getCost
public int getCost()Description copied from class:Expression
Estimate the cost to process the expression. Used when optimizing the query, to calculate the query plan with the lowest estimated cost.- Specified by:
getCost
in classExpression
- Returns:
- the estimated cost
-
getUnenclosedSQL
Description copied from class:Expression
Get the SQL statement of this expression. This may not always be the original SQL statement, especially after optimization. Enclosing '(' and ')' are never appended.- Specified by:
getUnenclosedSQL
in classExpression
- Parameters:
builder
- string buildersqlFlags
- formatting flags- Returns:
- the specified string builder
-
isEverything
Description copied from class:Expression
Check if this expression and all sub-expressions can fulfill a criteria. If any part returns false, the result is false.- Overrides:
isEverything
in classDataAnalysisOperation
- Parameters:
visitor
- the visitor- Returns:
- if the criteria can be fulfilled
-
optimize
Description copied from class:Expression
Try to optimize the expression.- Overrides:
optimize
in classAbstractAggregate
- Parameters:
session
- the session- Returns:
- the optimized expression
-
getInstance
-
getAggregatedValue
Description copied from class:DataAnalysisOperation
Returns aggregated value.- Specified by:
getAggregatedValue
in classDataAnalysisOperation
- Parameters:
session
- the sessionaggregateData
- the aggregate data- Returns:
- aggregated value.
-
updateAggregate
Description copied from class:AbstractAggregate
Updates an aggregate value.- Specified by:
updateAggregate
in classAbstractAggregate
- Parameters:
session
- the sessionaggregateData
- aggregate data
-
updateData
-
updateGroupAggregates
Description copied from class:DataAnalysisOperation
Invoked when processing group stage of grouped window queries to update arguments of this aggregate.- Overrides:
updateGroupAggregates
in classAbstractAggregate
- Parameters:
session
- the sessionstage
- select stage
-
getNumExpressions
protected int getNumExpressions()Description copied from class:DataAnalysisOperation
Returns the number of expressions, excluding OVER clause.- Specified by:
getNumExpressions
in classDataAnalysisOperation
- Returns:
- the number of expressions
-
rememberExpressions
Description copied from class:DataAnalysisOperation
Stores current values of expressions into the specified array.- Specified by:
rememberExpressions
in classDataAnalysisOperation
- Parameters:
session
- the sessionarray
- array to store values of expressions
-
updateFromExpressions
Description copied from class:AbstractAggregate
Updates the provided aggregate data from the remembered expressions.- Specified by:
updateFromExpressions
in classAbstractAggregate
- Parameters:
session
- the sessionaggregateData
- aggregate dataarray
- values of expressions
-
createAggregateData
Description copied from class:DataAnalysisOperation
Create aggregate data object specific to the subclass.- Specified by:
createAggregateData
in classDataAnalysisOperation
- Returns:
- aggregate-specific data object.
-