Top Description Fields Constructors Methods
org.h2.expression.aggregate

public Class JavaAggregate

extends AbstractAggregate
Class Inheritance
Imports
java.sql.SQLException, org.h2.api.Aggregate, org.h2.command.query.Select, org.h2.engine.SessionLocal, org.h2.expression.Expression, .ExpressionVisitor, org.h2.expression.aggregate.AggregateDataCollecting.NullCollectionMode, org.h2.jdbc.JdbcConnection, org.h2.message.DbException, org.h2.schema.UserAggregate, org.h2.util.ParserUtil, org.h2.value.TypeInfo, .Value, .ValueBoolean, .ValueNull, .ValueRow, .ValueToObjectConverter

This class wraps a user-defined aggregate.

Field Summary

Modifier and TypeField and Description
private int[]
private int
private final UserAggregate
private JdbcConnection
Inherited from org.h2.expression.aggregate.AbstractAggregate:
argsdistinctfilterConditiontype

Constructor Summary

AccessConstructor and Description
public
JavaAggregate(UserAggregate userAggregate, Expression[] args, Select select, boolean distinct)

Method Summary

Modifier and TypeMethod and Description
protected Object
createAggregateData()

Implements abstract org.h2.expression.analysis.DataAnalysisOperation.createAggregateData.

Create aggregate data object specific to the subclass.

public Value
getAggregatedValue(SessionLocal
the session
session
,
Object
the aggregate data
aggregateData
)

Implements abstract org.h2.expression.analysis.DataAnalysisOperation.getAggregatedValue.

Returns aggregated value.

public int
getCost()

Implements abstract org.h2.expression.Expression.getCost.

Estimate the cost to process the expression.

private Aggregate
protected int
getNumExpressions()

Implements abstract org.h2.expression.analysis.DataAnalysisOperation.getNumExpressions.

Returns the number of expressions, excluding OVER clause.

public StringBuilder
getUnenclosedSQL(StringBuilder
string builder
builder
,
int
formatting flags
sqlFlags
)

Implements abstract org.h2.expression.Expression.getUnenclosedSQL.

Get the SQL statement of this expression.

public boolean
isEverything(ExpressionVisitor
the visitor
visitor
)

Overrides org.h2.expression.analysis.DataAnalysisOperation.isEverything.

Check if this expression and all sub-expressions can fulfill a criteria.

public Expression
optimize(SessionLocal
the session
session
)

Overrides org.h2.expression.aggregate.AbstractAggregate.optimize.

Try to optimize the expression.

protected void
rememberExpressions(SessionLocal
the session
session
,
Value[]
array to store values of expressions
array
)

Implements abstract org.h2.expression.analysis.DataAnalysisOperation.rememberExpressions.

Stores current values of expressions into the specified array.

protected void
updateAggregate(SessionLocal
the session
session
,
Object
aggregate data
aggregateData
)

Implements abstract org.h2.expression.aggregate.AbstractAggregate.updateAggregate.

Updates an aggregate value.

private void
updateData(SessionLocal session, Object aggregateData, Value[] remembered)

protected void
updateFromExpressions(SessionLocal
the session
session
,
Object
aggregate data
aggregateData
,
Value[]
values of expressions
array
)

Implements abstract org.h2.expression.aggregate.AbstractAggregate.updateFromExpressions.

Updates the provided aggregate data from the remembered expressions.

protected void
updateGroupAggregates(SessionLocal
the session
session
,
int
select stage
stage
)

Overrides org.h2.expression.aggregate.AbstractAggregate.updateGroupAggregates.

Invoked when processing group stage of grouped window queries to update arguments of this aggregate.

Inherited from org.h2.expression.aggregate.AbstractAggregate:
appendTailConditionsgetFilterConditiongetOrderedResultLoopgetSubexpressiongetSubexpressionCountgetTypeisAggregatemapColumnsAnalysissetEvaluatablesetFilterConditionupdateAggregate

Field Detail

argTypesback to summary
private int[] argTypes
dataTypeback to summary
private int dataType
userAggregateback to summary
private final UserAggregate userAggregate
userConnectionback to summary
private JdbcConnection userConnection

Constructor Detail

JavaAggregateback to summary
public JavaAggregate(UserAggregate userAggregate, Expression[] args, Select select, boolean distinct)

Method Detail

createAggregateDataback to summary
protected Object createAggregateData()

Implements abstract org.h2.expression.analysis.DataAnalysisOperation.createAggregateData.

Doc from org.h2.expression.analysis.DataAnalysisOperation.createAggregateData.

Create aggregate data object specific to the subclass.

Returns:Object

aggregate-specific data object.

Annotations
@Override
getAggregatedValueback to summary
public Value getAggregatedValue(SessionLocal session, Object aggregateData)

Implements abstract org.h2.expression.analysis.DataAnalysisOperation.getAggregatedValue.

Doc from org.h2.expression.analysis.DataAnalysisOperation.getAggregatedValue.

Returns aggregated value.

Parameters
session:SessionLocal

the session

aggregateData:Object

the aggregate data

Returns:Value

aggregated value.

Annotations
@Override
getCostback to summary
public int getCost()

Implements abstract org.h2.expression.Expression.getCost.

Doc from org.h2.expression.Expression.getCost.

Estimate the cost to process the expression. Used when optimizing the query, to calculate the query plan with the lowest estimated cost.

Returns:int

the estimated cost

Annotations
@Override
getInstanceback to summary
private Aggregate getInstance()
getNumExpressionsback to summary
protected int getNumExpressions()

Implements abstract org.h2.expression.analysis.DataAnalysisOperation.getNumExpressions.

Doc from org.h2.expression.analysis.DataAnalysisOperation.getNumExpressions.

Returns the number of expressions, excluding OVER clause.

Returns:int

the number of expressions

Annotations
@Override
getUnenclosedSQLback to summary
public StringBuilder getUnenclosedSQL(StringBuilder builder, int sqlFlags)

Implements abstract org.h2.expression.Expression.getUnenclosedSQL.

Doc from org.h2.expression.Expression.getUnenclosedSQL.

Get the SQL statement of this expression. This may not always be the original SQL statement, especially after optimization. Enclosing '(' and ')' are never appended.

Parameters
builder:StringBuilder

string builder

sqlFlags:int

formatting flags

Returns:StringBuilder

the specified string builder

Annotations
@Override
isEverythingback to summary
public boolean isEverything(ExpressionVisitor visitor)

Overrides org.h2.expression.analysis.DataAnalysisOperation.isEverything.

Doc from org.h2.expression.Expression.isEverything.

Check if this expression and all sub-expressions can fulfill a criteria. If any part returns false, the result is false.

Parameters
visitor:ExpressionVisitor

the visitor

Returns:boolean

if the criteria can be fulfilled

Annotations
@Override
optimizeback to summary
public Expression optimize(SessionLocal session)

Overrides org.h2.expression.aggregate.AbstractAggregate.optimize.

Doc from org.h2.expression.Expression.optimize.

Try to optimize the expression.

Parameters
session:SessionLocal

the session

Returns:Expression

the optimized expression

Annotations
@Override
rememberExpressionsback to summary
protected void rememberExpressions(SessionLocal session, Value[] array)

Implements abstract org.h2.expression.analysis.DataAnalysisOperation.rememberExpressions.

Doc from org.h2.expression.analysis.DataAnalysisOperation.rememberExpressions.

Stores current values of expressions into the specified array.

Parameters
session:SessionLocal

the session

array:Value[]

array to store values of expressions

Annotations
@Override
updateAggregateback to summary
protected void updateAggregate(SessionLocal session, Object aggregateData)

Implements abstract org.h2.expression.aggregate.AbstractAggregate.updateAggregate.

Doc from org.h2.expression.aggregate.AbstractAggregate.updateAggregate.

Updates an aggregate value.

Parameters
session:SessionLocal

the session

aggregateData:Object

aggregate data

Annotations
@Override
updateDataback to summary
private void updateData(SessionLocal session, Object aggregateData, Value[] remembered)
updateFromExpressionsback to summary
protected void updateFromExpressions(SessionLocal session, Object aggregateData, Value[] array)

Implements abstract org.h2.expression.aggregate.AbstractAggregate.updateFromExpressions.

Doc from org.h2.expression.aggregate.AbstractAggregate.updateFromExpressions.

Updates the provided aggregate data from the remembered expressions.

Parameters
session:SessionLocal

the session

aggregateData:Object

aggregate data

array:Value[]

values of expressions

Annotations
@Override
updateGroupAggregatesback to summary
protected void updateGroupAggregates(SessionLocal session, int stage)

Overrides org.h2.expression.aggregate.AbstractAggregate.updateGroupAggregates.

Doc from org.h2.expression.analysis.DataAnalysisOperation.updateGroupAggregates.

Invoked when processing group stage of grouped window queries to update arguments of this aggregate.

Parameters
session:SessionLocal

the session

stage:int

select stage

Annotations
@Override