Class LateralJoinBatch
java.lang.Object
org.apache.drill.exec.record.AbstractRecordBatch<T>
org.apache.drill.exec.record.AbstractBinaryRecordBatch<LateralJoinPOP>
org.apache.drill.exec.physical.impl.join.LateralJoinBatch
- All Implemented Interfaces:
AutoCloseable
,Iterable<VectorWrapper<?>>
,LateralContract
,CloseableRecordBatch
,RecordBatch
,VectorAccessible
public class LateralJoinBatch
extends AbstractBinaryRecordBatch<LateralJoinPOP>
implements LateralContract
RecordBatch implementation for the lateral join operator. Currently it's
expected LATERAL to co-exists with UNNEST operator. Both LATERAL and UNNEST
will share a contract with each other defined at
LateralContract
.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.drill.exec.record.AbstractBinaryRecordBatch
AbstractBinaryRecordBatch.Metric
Nested classes/interfaces inherited from class org.apache.drill.exec.record.AbstractRecordBatch
AbstractRecordBatch.BatchState
Nested classes/interfaces inherited from interface org.apache.drill.exec.record.RecordBatch
RecordBatch.IterOutcome
-
Field Summary
Fields inherited from class org.apache.drill.exec.record.AbstractBinaryRecordBatch
batchMemoryManager, left, LEFT_INDEX, leftUpstream, numInputs, right, RIGHT_INDEX, rightUpstream
Fields inherited from class org.apache.drill.exec.record.AbstractRecordBatch
batchStatsContext, container, context, oContext, popConfig, state, stats, unionTypeEnabled
Fields inherited from interface org.apache.drill.exec.record.RecordBatch
MAX_BATCH_ROW_COUNT
-
Constructor Summary
ConstructorDescriptionLateralJoinBatch
(LateralJoinPOP popConfig, FragmentContext context, RecordBatch left, RecordBatch right) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Prefetch a batch from left and right branch to know about the schema of each side.protected void
void
close()
void
dump()
Perform dump of this batch's state to logs.Returns the left side incoming for the Lateral Join.Returns the currentRecordBatch.IterOutcome
for the left incoming batchint
Get the number of records.int
Returns the current row index which the calling operator should process in current incoming left record batch.Gets the left and right incoming batch and produce the output batch.protected boolean
Get the left and right batch during build schema phase forLateralJoinBatch
.void
setMaxOutputRowCount
(int outputRowCount) Used only for testing for cases when multiple output batches are produced for same input setvoid
setUseMemoryManager
(boolean useMemoryManager) Used only for testing to disable output batch calculation using memory manager and instead use the static max value set bysetMaxOutputRowCount(int)
Methods inherited from class org.apache.drill.exec.record.AbstractBinaryRecordBatch
checkForEarlyFinish, getBatchMemoryManager, updateBatchMemoryManagerStats, verifyOutcomeToSetBatchState
Methods inherited from class org.apache.drill.exec.record.AbstractRecordBatch
cancel, checkContinue, getContainer, getContext, getOutgoingContainer, getPopConfig, getRecordBatchStatsContext, getSchema, getSelectionVector2, getSelectionVector4, getValueAccessorById, getValueVectorId, getWritableBatch, isRecordBatchStatsLoggingEnabled, iterator, next, next, next, schemaChangeException, schemaChangeException
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
LateralJoinBatch
public LateralJoinBatch(LateralJoinPOP popConfig, FragmentContext context, RecordBatch left, RecordBatch right) throws OutOfMemoryException - Throws:
OutOfMemoryException
-
-
Method Details
-
innerNext
Gets the left and right incoming batch and produce the output batch. If the left incoming batch is empty then next on right branch is not called and empty batch with correct outcome is returned. If non empty left incoming batch is received then it call's next on right branch to get an incoming and finally produces output.- Specified by:
innerNext
in classAbstractRecordBatch<LateralJoinPOP>
- Returns:
- IterOutcome state of the lateral join batch
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Overrides:
close
in classAbstractRecordBatch<LateralJoinPOP>
-
getRecordCount
public int getRecordCount()Description copied from interface:VectorAccessible
Get the number of records.- Specified by:
getRecordCount
in interfaceVectorAccessible
- Returns:
- number of records
-
getIncoming
Returns the left side incoming for the Lateral Join. Used by right branch leaf operator of Lateral to process the records atleftJoinIndex
.- Specified by:
getIncoming
in interfaceLateralContract
- Returns:
- - RecordBatch received as left side incoming
-
getRecordIndex
public int getRecordIndex()Returns the current row index which the calling operator should process in current incoming left record batch. LATERAL should never return it as -1 since that indicated current left batch is empty and LATERAL will never call next on right side with empty left batch- Specified by:
getRecordIndex
in interfaceLateralContract
- Returns:
- - int - index of row to process.
-
getLeftOutcome
Returns the currentRecordBatch.IterOutcome
for the left incoming batch- Specified by:
getLeftOutcome
in interfaceLateralContract
- Returns:
- The current outcome of left incoming batch.
-
prefetchFirstBatchFromBothSides
protected boolean prefetchFirstBatchFromBothSides()Get the left and right batch during build schema phase forLateralJoinBatch
. If left batch sees a failure outcome then we don't even call next on right branch, since there is no left incoming.- Overrides:
prefetchFirstBatchFromBothSides
in classAbstractBinaryRecordBatch<LateralJoinPOP>
- Returns:
- true if both the left/right batch was received without failure outcome. false if either of batch is received with failure outcome.
-
buildSchema
protected void buildSchema()Prefetch a batch from left and right branch to know about the schema of each side. Then adds value vector in output container based on those schemas. For this phase LATERAL always expect's an empty batch from right side which UNNEST should abide by.- Overrides:
buildSchema
in classAbstractRecordBatch<LateralJoinPOP>
- Throws:
SchemaChangeException
- if batch schema was changed during execution
-
cancelIncoming
protected void cancelIncoming()- Overrides:
cancelIncoming
in classAbstractBinaryRecordBatch<LateralJoinPOP>
-
setMaxOutputRowCount
public void setMaxOutputRowCount(int outputRowCount) Used only for testing for cases when multiple output batches are produced for same input set- Parameters:
outputRowCount
- - Max rows that output batch can hold
-
setUseMemoryManager
public void setUseMemoryManager(boolean useMemoryManager) Used only for testing to disable output batch calculation using memory manager and instead use the static max value set bysetMaxOutputRowCount(int)
- Parameters:
useMemoryManager
- - false - disable memory manager update to take effect, true enable memory manager update
-
dump
public void dump()Description copied from interface:RecordBatch
Perform dump of this batch's state to logs.- Specified by:
dump
in interfaceRecordBatch
-