Class NoFrameSupportTemplate
java.lang.Object
org.apache.drill.exec.physical.impl.window.NoFrameSupportTemplate
- All Implemented Interfaces:
WindowFramer
WindowFramer implementation that doesn't support the FRAME clause (will
assume the default frame).
According to the SQL standard, LEAD, LAG, ROW_NUMBER, NTILE and all ranking functions don't support the FRAME clause. This class will handle such functions.
-
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()
abstract void
copyFromInternal
(int inIndex, int outIndex) abstract void
copyNext
(int inIndex, int outIndex) Copies value(s) from inIndex row to outIndex row.abstract void
copyPrev
(int inIndex, int outIndex) Copies value(s) from inIndex row to outIndex row.void
doWork()
Processes all rows of the first batch.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
Called once for each row after we evaluate all peer rows.abstract boolean
Reset all window functionsvoid
setup
(List<WindowDataBatch> batches, VectorContainer container, OperatorContext oContext, boolean requireFullPartition, WindowPOP popConfig) abstract void
setupCopyFromInternal
(VectorAccessible incoming, VectorAccessible outgoing) abstract void
setupCopyNext
(VectorAccessible incoming, VectorAccessible outgoing) abstract void
setupCopyPrev
(VectorAccessible incoming, VectorAccessible outgoing) abstract void
setupPartition
(WindowDataBatch incoming, VectorAccessible outgoing) Called once per partition, before processing the partition.toString()
-
Constructor Details
-
NoFrameSupportTemplate
public NoFrameSupportTemplate()
-
-
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
public void doWork()Processes all rows of the first batch.- Specified by:
doWork
in interfaceWindowFramer
-
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
-
outputRow
public abstract void outputRow(@Named("outIndex") int outIndex, @Named("partition") Partition partition) throws SchemaChangeException Called once for each row after we evaluate all peer rows. Used to write a value in the row- Parameters:
outIndex
- index of rowpartition
- object used by "computed" window functions- Throws:
SchemaChangeException
-
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
-
copyNext
public abstract void copyNext(@Named("inIndex") int inIndex, @Named("outIndex") int outIndex) throws SchemaChangeException Copies value(s) from inIndex row to outIndex row. Mostly used by LEAD. inIndex always points to the row next to outIndex- Parameters:
inIndex
- source row of the copyoutIndex
- destination row of the copy.- Throws:
SchemaChangeException
-
setupCopyNext
public abstract void setupCopyNext(@Named("incoming") VectorAccessible incoming, @Named("outgoing") VectorAccessible outgoing) throws SchemaChangeException - Throws:
SchemaChangeException
-
copyPrev
public abstract void copyPrev(@Named("inIndex") int inIndex, @Named("outIndex") int outIndex) throws SchemaChangeException Copies value(s) from inIndex row to outIndex row. Mostly used by LAG. inIndex always points to the previous row- Parameters:
inIndex
- source row of the copyoutIndex
- destination row of the copy.- Throws:
SchemaChangeException
-
setupCopyPrev
public abstract void setupCopyPrev(@Named("incoming") VectorAccessible incoming, @Named("outgoing") VectorAccessible outgoing) throws SchemaChangeException - Throws:
SchemaChangeException
-
copyFromInternal
public abstract void copyFromInternal(@Named("inIndex") int inIndex, @Named("outIndex") int outIndex) throws SchemaChangeException - Throws:
SchemaChangeException
-
setupCopyFromInternal
public abstract void setupCopyFromInternal(@Named("incoming") VectorAccessible incoming, @Named("outgoing") VectorAccessible outgoing) throws SchemaChangeException - Throws:
SchemaChangeException
-
resetValues
Reset all window functions- Throws:
SchemaChangeException
-
isSamePartition
public abstract boolean isSamePartition(@Named("b1Index") int b1Index, @Named("b1") VectorAccessible b1, @Named("b2Index") int b2Index, @Named("b2") VectorAccessible b2) throws SchemaChangeException 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
- Throws:
SchemaChangeException
-
isPeer
public abstract boolean isPeer(@Named("b1Index") int b1Index, @Named("b1") VectorAccessible b1, @Named("b2Index") int b2Index, @Named("b2") VectorAccessible b2) throws SchemaChangeException 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
- Throws:
SchemaChangeException
-