Class RexImpTable.LagImplementor
java.lang.Object
org.apache.calcite.adapter.enumerable.RexImpTable.LagImplementor
- All Implemented Interfaces:
AggImplementor
,WinAggImplementor
- Enclosing class:
RexImpTable
Implementor for the
LAG
windowed aggregate function.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.calcite.adapter.enumerable.WinAggImplementor
WinAggImplementor.SeekType
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetStateType
(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.implementResult
(AggContext info, AggResultContext result) Calculates the resulting value based on the intermediate variables.boolean
-
Constructor Details
-
LagImplementor
protected LagImplementor()
-
-
Method Details
-
getStateType
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
-
implementReset
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
-
implementAdd
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
-
needCacheWhenFrameIntact
public boolean needCacheWhenFrameIntact()- Specified by:
needCacheWhenFrameIntact
in interfaceWinAggImplementor
-
implementResult
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
-