Class FrameSupportTemplate
java.lang.Object
org.apache.drill.exec.physical.impl.window.FrameSupportTemplate
- All Implemented Interfaces:
WindowFramer
WindowFramer implementation that supports the FRAME clause.
According to the SQL specification, FIRST_VALUE, LAST_VALUE and all aggregate functions support the FRAME clause. This class will handle such functions even if the FRAME clause is not present.
According to the SQL specification, FIRST_VALUE, LAST_VALUE and all aggregate functions support the FRAME clause. This class will handle such functions even if the FRAME clause is not present.
-
Field Summary
Fields inherited from interface org.apache.drill.exec.physical.impl.window.WindowFramer
FRAME_TEMPLATE_DEFINITION, NOFRAME_TEMPLATE_DEFINITION
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanup()
void
doWork()
processes all rows of the first batch.abstract void
evaluatePeer
(int index) called once for each peer row of the current frame.int
abstract boolean
isPeer
(int b1Index, VectorAccessible b1, int b2Index, VectorAccessible b2) compares two rows from different batches (can be the same), if they have the same value for the order by expressionabstract boolean
isSamePartition
(int b1Index, VectorAccessible b1, int b2Index, VectorAccessible b2) compares two rows from different batches (can be the same), if they have the same value for the partition by expressionabstract void
outputRow
(int outIndex) called once for each row after we evaluate all peer rows.abstract boolean
reset all window functionsabstract void
saveFirstValue
(int index) void
setup
(List<WindowDataBatch> batches, VectorContainer container, OperatorContext oContext, boolean requireFullPartition, WindowPOP popConfig) abstract void
setupEvaluatePeer
(VectorAccessible incoming, VectorAccessible outgoing) abstract void
setupPartition
(WindowDataBatch incoming, VectorAccessible outgoing) Called once per partition, before processing the partition.abstract void
setupReadLastValue
(VectorAccessible incoming, VectorAccessible outgoing) abstract void
setupSaveFirstValue
(VectorAccessible incoming, VectorAccessible outgoing) abstract void
setupWriteFirstValue
(VectorAccessible incoming, VectorAccessible outgoing) toString()
abstract void
writeLastValue
(int index, int outIndex)
-
Constructor Details
-
FrameSupportTemplate
public FrameSupportTemplate()
-
-
Method Details
-
setup
public void setup(List<WindowDataBatch> batches, VectorContainer container, OperatorContext oContext, boolean requireFullPartition, WindowPOP popConfig) throws SchemaChangeException - Specified by:
setup
in interfaceWindowFramer
- Throws:
SchemaChangeException
-
doWork
processes all rows of the first batch.- Specified by:
doWork
in interfaceWindowFramer
- Throws:
SchemaChangeException
-
getOutputCount
public int getOutputCount()- Specified by:
getOutputCount
in interfaceWindowFramer
- Returns:
- number rows processed in last batch
-
cleanup
public void cleanup()- Specified by:
cleanup
in interfaceWindowFramer
-
toString
-
evaluatePeer
public abstract void evaluatePeer(@Named("index") int index) called once for each peer row of the current frame.- Parameters:
index
- of row to aggregate
-
setupEvaluatePeer
public abstract void setupEvaluatePeer(@Named("incoming") VectorAccessible incoming, @Named("outgoing") VectorAccessible outgoing) throws SchemaChangeException - Throws:
SchemaChangeException
-
setupReadLastValue
public abstract void setupReadLastValue(@Named("incoming") VectorAccessible incoming, @Named("outgoing") VectorAccessible outgoing) throws SchemaChangeException - Throws:
SchemaChangeException
-
writeLastValue
public abstract void writeLastValue(@Named("index") int index, @Named("outIndex") int outIndex) -
setupSaveFirstValue
public abstract void setupSaveFirstValue(@Named("incoming") VectorAccessible incoming, @Named("outgoing") VectorAccessible outgoing) throws SchemaChangeException - Throws:
SchemaChangeException
-
saveFirstValue
public abstract void saveFirstValue(@Named("index") int index) -
setupWriteFirstValue
public abstract void setupWriteFirstValue(@Named("incoming") VectorAccessible incoming, @Named("outgoing") VectorAccessible outgoing) -
outputRow
public abstract void outputRow(@Named("outIndex") int outIndex) called once for each row after we evaluate all peer rows. Used to write a value in the row- Parameters:
outIndex
- index of row
-
setupPartition
public abstract void setupPartition(@Named("incoming") WindowDataBatch incoming, @Named("outgoing") VectorAccessible outgoing) throws SchemaChangeException Called once per partition, before processing the partition. Used to setup read/write vectors- Parameters:
incoming
- batch we will read fromoutgoing
- batch we will be writing to- Throws:
SchemaChangeException
-
resetValues
public abstract boolean resetValues()reset all window functions -
isSamePartition
public abstract boolean isSamePartition(@Named("b1Index") int b1Index, @Named("b1") VectorAccessible b1, @Named("b2Index") int b2Index, @Named("b2") VectorAccessible b2) compares two rows from different batches (can be the same), if they have the same value for the partition by expression- Specified by:
isSamePartition
in interfaceWindowFramer
- Parameters:
b1Index
- index of first rowb1
- batch for first rowb2Index
- index of second rowb2
- batch for second row- Returns:
- true if the rows are in the same partition
-
isPeer
public abstract boolean isPeer(@Named("b1Index") int b1Index, @Named("b1") VectorAccessible b1, @Named("b2Index") int b2Index, @Named("b2") VectorAccessible b2) compares two rows from different batches (can be the same), if they have the same value for the order by expression- Specified by:
isPeer
in interfaceWindowFramer
- Parameters:
b1Index
- index of first rowb1
- batch for first rowb2Index
- index of second rowb2
- batch for second row- Returns:
- true if the rows are in the same partition
-