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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup()voiddoWork()processes all rows of the first batch.abstract voidevaluatePeer(int index) called once for each peer row of the current frame.intabstract booleanisPeer(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 booleanisSamePartition(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 voidoutputRow(int outIndex) called once for each row after we evaluate all peer rows.abstract booleanreset all window functionsabstract voidsaveFirstValue(int index) voidsetup(List<WindowDataBatch> batches, VectorContainer container, OperatorContext oContext, boolean requireFullPartition, WindowPOP popConfig) abstract voidsetupEvaluatePeer(VectorAccessible incoming, VectorAccessible outgoing) abstract voidsetupPartition(WindowDataBatch incoming, VectorAccessible outgoing) Called once per partition, before processing the partition.abstract voidsetupReadLastValue(VectorAccessible incoming, VectorAccessible outgoing) abstract voidsetupSaveFirstValue(VectorAccessible incoming, VectorAccessible outgoing) abstract voidsetupWriteFirstValue(VectorAccessible incoming, VectorAccessible outgoing) toString()abstract voidwriteLastValue(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:
setupin interfaceWindowFramer- Throws:
SchemaChangeException
-
doWork
processes all rows of the first batch.- Specified by:
doWorkin interfaceWindowFramer- Throws:
SchemaChangeException
-
getOutputCount
public int getOutputCount()- Specified by:
getOutputCountin interfaceWindowFramer- Returns:
- number rows processed in last batch
-
cleanup
public void cleanup()- Specified by:
cleanupin 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:
isSamePartitionin 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:
isPeerin 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
-