Class WinAggResultContextImpl
- java.lang.Object
-
- org.apache.calcite.adapter.enumerable.NestedBlockBuilderImpl
-
- org.apache.calcite.adapter.enumerable.impl.AggResetContextImpl
-
- org.apache.calcite.adapter.enumerable.impl.AggResultContextImpl
-
- org.apache.calcite.adapter.enumerable.impl.WinAggResultContextImpl
-
- All Implemented Interfaces:
AggResetContext
,AggResultContext
,NestedBlockBuilder
,WinAggFrameContext
,WinAggFrameResultContext
,WinAggResultContext
- Direct Known Subclasses:
WinAggAddContextImpl
public abstract class WinAggResultContextImpl extends AggResultContextImpl implements WinAggResultContext
Implementation ofWinAggResultContext
.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.Function<BlockBuilder,WinAggFrameResultContext>
frame
-
Constructor Summary
Constructors Constructor Description WinAggResultContextImpl(BlockBuilder block, java.util.List<Expression> accumulator, com.google.common.base.Function<BlockBuilder,WinAggFrameResultContext> frameContextBuilder)
Deprecated.WinAggResultContextImpl(BlockBuilder block, java.util.List<Expression> accumulator, java.util.function.Function<BlockBuilder,WinAggFrameResultContext> frameContextBuilder)
Creates window aggregate result context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<Expression>
arguments(Expression rowIndex)
Returns Linq4j form of arguments.Expression
compareRows(Expression a, Expression b)
Compares two rows given by absolute positions according to the order collation of the current window.Expression
computeIndex(Expression offset, WinAggImplementor.SeekType seekType)
Converts absolute index position of the given relative position.Expression
endIndex()
Returns the index of the very last row in partition.private WinAggFrameResultContext
getFrame()
Expression
getFrameRowCount()
Returns the number of rows in the current frame (subject to framing clause).Expression
getPartitionRowCount()
Returns the number of rows in the current partition (as determined by PARTITION BY clause).Expression
hasRows()
Returns the boolean expression that tells if the partition has rows.Expression
index()
Returns the index of the current row in the partition.Expression
rowInFrame(Expression rowIndex)
Returns boolean the expression that checks if the given index is in the frame bounds.Expression
rowInPartition(Expression rowIndex)
Returns boolean the expression that checks if the given index is in the partition bounds.RexToLixTranslator
rowTranslator(Expression rowIndex)
Returns row translator for given absolute row position.Expression
startIndex()
Returns the index of the very first row in partition.-
Methods inherited from class org.apache.calcite.adapter.enumerable.impl.AggResultContextImpl
call, key, keyField
-
Methods inherited from class org.apache.calcite.adapter.enumerable.impl.AggResetContextImpl
accumulator
-
Methods inherited from class org.apache.calcite.adapter.enumerable.NestedBlockBuilderImpl
currentBlock, currentNullables, exitBlock, nestBlock, nestBlock, nestBlock
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.calcite.adapter.enumerable.AggResetContext
accumulator
-
Methods inherited from interface org.apache.calcite.adapter.enumerable.AggResultContext
call, key, keyField
-
Methods inherited from interface org.apache.calcite.adapter.enumerable.NestedBlockBuilder
currentBlock, currentNullables, exitBlock, nestBlock, nestBlock, nestBlock
-
Methods inherited from interface org.apache.calcite.adapter.enumerable.WinAggResultContext
rexArguments
-
-
-
-
Field Detail
-
frame
private final java.util.function.Function<BlockBuilder,WinAggFrameResultContext> frame
-
-
Constructor Detail
-
WinAggResultContextImpl
public WinAggResultContextImpl(BlockBuilder block, java.util.List<Expression> accumulator, java.util.function.Function<BlockBuilder,WinAggFrameResultContext> frameContextBuilder)
Creates window aggregate result context.- Parameters:
block
- code block that will contain the added initializationaccumulator
- accumulator variables that store the intermediate aggregate state
-
WinAggResultContextImpl
@Deprecated public WinAggResultContextImpl(BlockBuilder block, java.util.List<Expression> accumulator, com.google.common.base.Function<BlockBuilder,WinAggFrameResultContext> frameContextBuilder)
Deprecated.
-
-
Method Detail
-
getFrame
private WinAggFrameResultContext getFrame()
-
arguments
public final java.util.List<Expression> arguments(Expression rowIndex)
Description copied from interface:WinAggResultContext
Returns Linq4j form of arguments. The resulting value is equivalent torowTranslator().translateList(rexArguments())
. This is handy if you need just operate on argument.- Specified by:
arguments
in interfaceWinAggResultContext
- Parameters:
rowIndex
- index of the requested row. The index must be in range of partition's startIndex and endIndex.- Returns:
- Linq4j form of arguments of the particular row
-
computeIndex
public Expression computeIndex(Expression offset, WinAggImplementor.SeekType seekType)
Description copied from interface:WinAggFrameResultContext
Converts absolute index position of the given relative position.- Specified by:
computeIndex
in interfaceWinAggFrameResultContext
- Parameters:
offset
- offset of the requested rowseekType
- the type of offset (start of window, end of window, etc)- Returns:
- absolute position of the requested row
-
rowInFrame
public Expression rowInFrame(Expression rowIndex)
Description copied from interface:WinAggFrameResultContext
Returns boolean the expression that checks if the given index is in the frame bounds.- Specified by:
rowInFrame
in interfaceWinAggFrameResultContext
- Parameters:
rowIndex
- index if the row to check- Returns:
- expression that validates frame bounds for the given index
-
rowInPartition
public Expression rowInPartition(Expression rowIndex)
Description copied from interface:WinAggFrameResultContext
Returns boolean the expression that checks if the given index is in the partition bounds.- Specified by:
rowInPartition
in interfaceWinAggFrameResultContext
- Parameters:
rowIndex
- index if the row to check- Returns:
- expression that validates partition bounds for the given index
-
rowTranslator
public RexToLixTranslator rowTranslator(Expression rowIndex)
Description copied from interface:WinAggFrameResultContext
Returns row translator for given absolute row position.- Specified by:
rowTranslator
in interfaceWinAggFrameResultContext
- Parameters:
rowIndex
- absolute index of the row.- Returns:
- translator for the requested row
-
compareRows
public Expression compareRows(Expression a, Expression b)
Description copied from interface:WinAggFrameResultContext
Compares two rows given by absolute positions according to the order collation of the current window.- Specified by:
compareRows
in interfaceWinAggFrameResultContext
- Parameters:
a
- absolute index of the first rowb
- absolute index of the second row- Returns:
- result of comparison as as in
Comparable.compareTo(T)
-
index
public Expression index()
Description copied from interface:WinAggFrameContext
Returns the index of the current row in the partition. In other words, it is close to ~ROWS BETWEEN CURRENT ROW. Note to useWinAggFrameContext.startIndex()
when you need zero-based row position.- Specified by:
index
in interfaceWinAggFrameContext
- Returns:
- the index of the very first row in partition
-
startIndex
public Expression startIndex()
Description copied from interface:WinAggFrameContext
Returns the index of the very first row in partition.- Specified by:
startIndex
in interfaceWinAggFrameContext
- Returns:
- index of the very first row in partition
-
endIndex
public Expression endIndex()
Description copied from interface:WinAggFrameContext
Returns the index of the very last row in partition.- Specified by:
endIndex
in interfaceWinAggFrameContext
- Returns:
- index of the very last row in partition
-
hasRows
public Expression hasRows()
Description copied from interface:WinAggFrameContext
Returns the boolean expression that tells if the partition has rows. The partition might lack rows in cases like ROWS BETWEEN 1000 PRECEDING AND 900 PRECEDING.- Specified by:
hasRows
in interfaceWinAggFrameContext
- Returns:
- boolean expression that tells if the partition has rows
-
getFrameRowCount
public Expression getFrameRowCount()
Description copied from interface:WinAggFrameContext
Returns the number of rows in the current frame (subject to framing clause).- Specified by:
getFrameRowCount
in interfaceWinAggFrameContext
- Returns:
- number of rows in the current partition or 0 if the partition is empty
-
getPartitionRowCount
public Expression getPartitionRowCount()
Description copied from interface:WinAggFrameContext
Returns the number of rows in the current partition (as determined by PARTITION BY clause).- Specified by:
getPartitionRowCount
in interfaceWinAggFrameContext
- Returns:
- number of rows in the current partition or 0 if the partition is empty
-
-