Interface AggImplementor
-
- All Known Subinterfaces:
WinAggImplementor
- All Known Implementing Classes:
RexImpTable.CollectImplementor
,RexImpTable.CountImplementor
,RexImpTable.CountWinImplementor
,RexImpTable.DenseRankImplementor
,RexImpTable.FirstLastValueImplementor
,RexImpTable.FirstValueImplementor
,RexImpTable.FusionImplementor
,RexImpTable.GroupingImplementor
,RexImpTable.JsonArrayAggImplementor
,RexImpTable.JsonObjectAggImplementor
,RexImpTable.LagImplementor
,RexImpTable.LastValueImplementor
,RexImpTable.LeadImplementor
,RexImpTable.LeadLagImplementor
,RexImpTable.MinMaxImplementor
,RexImpTable.NthValueImplementor
,RexImpTable.NtileImplementor
,RexImpTable.RankImplementor
,RexImpTable.RowNumberImplementor
,RexImpTable.SingleValueImplementor
,RexImpTable.SumImplementor
,RexImpTable.UserDefinedAggReflectiveImplementor
,StrictAggImplementor
,StrictWinAggImplementor
public interface AggImplementor
Implements an aggregate function by generating expressions to initialize, add to, and get a result from, an accumulator.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.List<java.lang.reflect.Type>
getStateType(AggContext info)
Returns the types of the intermediate variables used by the aggregate implementation.void
implementAdd(AggContext info, AggAddContext add)
Updates intermediate values to account for the newly added value.void
implementReset(AggContext info, AggResetContext reset)
Implements reset of the intermediate variables to the initial state.Expression
implementResult(AggContext info, AggResultContext result)
Calculates the resulting value based on the intermediate variables.
-
-
-
Method Detail
-
getStateType
java.util.List<java.lang.reflect.Type> getStateType(AggContext info)
Returns the types of the intermediate variables used by the aggregate implementation.For instance, for "concatenate to string" this can be
StringBuilder
. Calcite calls this method before all otherimplement*
methods.- Parameters:
info
- Aggregate context- Returns:
- Types of the intermediate variables used by the aggregate implementation
-
implementReset
void implementReset(AggContext info, AggResetContext reset)
Implements reset of the intermediate variables to the initial state.AggResetContext.accumulator()
should be used to reference the state variables. For instance, to zero the count, use the following code:reset.currentBlock().add(
Expressions.statement(
Expressions.assign(reset.accumulator().get(0),
Expressions.constant(0)));- Parameters:
info
- Aggregate contextreset
- Reset context
-
implementAdd
void implementAdd(AggContext info, AggAddContext add)
Updates intermediate values to account for the newly added value.AggResetContext.accumulator()
should be used to reference the state variables.- Parameters:
info
- Aggregate contextadd
- Add context
-
implementResult
Expression implementResult(AggContext info, AggResultContext result)
Calculates the resulting value based on the intermediate variables. Note: this method must NOT destroy the intermediate variables as calcite might reuse the state when calculating sliding aggregates.AggResetContext.accumulator()
should be used to reference the state variables.- Parameters:
info
- Aggregate contextresult
- Result context- Returns:
- Expression that is a result of calculating final value of the aggregate being implemented
-
-