static class RexImpTable.FirstLastValueImplementor extends java.lang.Object implements WinAggImplementor
FIRST_VALUE
and LAST_VALUE
windowed aggregate functions.WinAggImplementor.SeekType
Modifier and Type | Field and Description |
---|---|
private WinAggImplementor.SeekType |
seekType |
Modifier | Constructor and Description |
---|---|
protected |
FirstLastValueImplementor(WinAggImplementor.SeekType seekType) |
Modifier and Type | Method and 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.
|
boolean |
needCacheWhenFrameIntact() |
private final WinAggImplementor.SeekType seekType
protected FirstLastValueImplementor(WinAggImplementor.SeekType seekType)
public java.util.List<java.lang.reflect.Type> getStateType(AggContext info)
AggImplementor
For instance, for "concatenate to string" this can be
StringBuilder
.
Calcite calls this method before all other implement*
methods.
getStateType
in interface AggImplementor
info
- Aggregate contextpublic void implementReset(AggContext info, AggResetContext reset)
AggImplementor
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)));
implementReset
in interface AggImplementor
info
- Aggregate contextreset
- Reset contextpublic void implementAdd(AggContext info, AggAddContext add)
AggImplementor
AggResetContext.accumulator()
should be used to reference
the state variables.implementAdd
in interface AggImplementor
info
- Aggregate contextadd
- Add contextpublic boolean needCacheWhenFrameIntact()
needCacheWhenFrameIntact
in interface WinAggImplementor
public Expression implementResult(AggContext info, AggResultContext result)
AggImplementor
AggResetContext.accumulator()
should be used to reference
the state variables.implementResult
in interface AggImplementor
info
- Aggregate contextresult
- Result contextCopyright © 2012–2019 The Apache Software Foundation. All rights reserved.