Class StrictAggImplementor
- java.lang.Object
-
- org.apache.calcite.adapter.enumerable.StrictAggImplementor
-
- All Implemented Interfaces:
AggImplementor
- Direct Known Subclasses:
RexImpTable.CollectImplementor
,RexImpTable.CountImplementor
,RexImpTable.FusionImplementor
,RexImpTable.MinMaxImplementor
,RexImpTable.SumImplementor
,RexImpTable.UserDefinedAggReflectiveImplementor
,StrictWinAggImplementor
public abstract class StrictAggImplementor extends java.lang.Object implements AggImplementor
The base implementation of strict aggregate function.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
needTrackEmptySet
private int
stateSize
private boolean
trackNullsPerRow
-
Constructor Summary
Constructors Constructor Description StrictAggImplementor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
accAdvance(AggAddContext add, Expression acc, Expression next)
private boolean
anyNullable(java.util.List<? extends RelDataType> types)
java.util.List<java.lang.reflect.Type>
getNotNullState(AggContext info)
protected int
getStateSize()
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.protected abstract void
implementNotNullAdd(AggContext info, AggAddContext add)
protected void
implementNotNullReset(AggContext info, AggResetContext reset)
protected Expression
implementNotNullResult(AggContext info, AggResultContext result)
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.protected boolean
nonDefaultOnEmptySet(AggContext info)
-
-
-
Method Detail
-
nonDefaultOnEmptySet
protected boolean nonDefaultOnEmptySet(AggContext info)
-
getStateSize
protected final int getStateSize()
-
accAdvance
protected final void accAdvance(AggAddContext add, Expression acc, Expression next)
-
getStateType
public final java.util.List<java.lang.reflect.Type> getStateType(AggContext info)
Description copied from interface:AggImplementor
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.- Specified by:
getStateType
in interfaceAggImplementor
- Parameters:
info
- Aggregate context- Returns:
- Types of the intermediate variables used by the aggregate implementation
-
anyNullable
private boolean anyNullable(java.util.List<? extends RelDataType> types)
-
getNotNullState
public java.util.List<java.lang.reflect.Type> getNotNullState(AggContext info)
-
implementReset
public final void implementReset(AggContext info, AggResetContext reset)
Description copied from interface:AggImplementor
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)));- Specified by:
implementReset
in interfaceAggImplementor
- Parameters:
info
- Aggregate contextreset
- Reset context
-
implementNotNullReset
protected void implementNotNullReset(AggContext info, AggResetContext reset)
-
implementAdd
public final void implementAdd(AggContext info, AggAddContext add)
Description copied from interface:AggImplementor
Updates intermediate values to account for the newly added value.AggResetContext.accumulator()
should be used to reference the state variables.- Specified by:
implementAdd
in interfaceAggImplementor
- Parameters:
info
- Aggregate contextadd
- Add context
-
implementNotNullAdd
protected abstract void implementNotNullAdd(AggContext info, AggAddContext add)
-
implementResult
public final Expression implementResult(AggContext info, AggResultContext result)
Description copied from interface:AggImplementor
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.- Specified by:
implementResult
in interfaceAggImplementor
- Parameters:
info
- Aggregate contextresult
- Result context- Returns:
- Expression that is a result of calculating final value of the aggregate being implemented
-
implementNotNullResult
protected Expression implementNotNullResult(AggContext info, AggResultContext result)
-
-