Class ResultSetCopierImpl
java.lang.Object
org.apache.drill.exec.physical.resultSet.impl.ResultSetCopierImpl
- All Implemented Interfaces:
ResultSetCopier
-
Field Summary
-
Constructor Summary
ConstructorDescriptionResultSetCopierImpl
(BufferAllocator allocator, PullResultSetReader source) ResultSetCopierImpl
(BufferAllocator allocator, PullResultSetReader source, ResultSetOptionBuilder outputOptions) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Release resources, including any pending input batch and any non-harvested output batch.void
Copy all (remaining) input rows to the output.boolean
If copying rows one by one, copy the next row from the input.void
copyRow
(int posn) Copy a row at the given position.harvest()
Obtain the output batch.boolean
Reports if the output batch has rows.boolean
Helper method to determine if a copy is pending: more rows remain to be copied.boolean
Reports if the output batch is full and must be sent downstream.boolean
Start the next input batch.void
Start the next output batch.protected void
-
Field Details
-
rowReader
-
-
Constructor Details
-
ResultSetCopierImpl
-
ResultSetCopierImpl
public ResultSetCopierImpl(BufferAllocator allocator, PullResultSetReader source, ResultSetOptionBuilder outputOptions)
-
-
Method Details
-
startOutputBatch
public void startOutputBatch()Description copied from interface:ResultSetCopier
Start the next output batch.- Specified by:
startOutputBatch
in interfaceResultSetCopier
-
nextInputBatch
public boolean nextInputBatch()Description copied from interface:ResultSetCopier
Start the next input batch. The input batch must be held by theResultSetReader
passed into the constructor.- Specified by:
nextInputBatch
in interfaceResultSetCopier
-
hasOutputRows
public boolean hasOutputRows()Description copied from interface:ResultSetCopier
Reports if the output batch has rows. Useful after the end of input to determine if a partial output batch exists to send downstream.- Specified by:
hasOutputRows
in interfaceResultSetCopier
- Returns:
- true if the output batch has one or more rows
-
isOutputFull
public boolean isOutputFull()Description copied from interface:ResultSetCopier
Reports if the output batch is full and must be sent downstream. The output batch can be full in the middle of a copy, in which caseResultSetCopier.isCopyPending()
will also return true.This function also returns true if a schema change occurred on the latest input row, in which case the partially-completed batch of the old schema must be flushed downstream.
- Specified by:
isOutputFull
in interfaceResultSetCopier
- Returns:
- true if the output is full and must be harvested and sent downstream
-
verifyWritable
protected void verifyWritable() -
copyNextRow
public boolean copyNextRow()Description copied from interface:ResultSetCopier
If copying rows one by one, copy the next row from the input.- Specified by:
copyNextRow
in interfaceResultSetCopier
- Returns:
- true if more rows remain on the input, false if all rows are exhausted
-
copyRow
public void copyRow(int posn) Description copied from interface:ResultSetCopier
Copy a row at the given position. For those cases in which random copying is needed, but a selection vector is not available. Note that this version is slow because of the need to reset indexes for every row. Better to use a selection vector, then copy sequentially.- Specified by:
copyRow
in interfaceResultSetCopier
- Parameters:
posn
- the input row position. If a selection vector is attached, then this is the selection vector position
-
copyAllRows
public void copyAllRows()Description copied from interface:ResultSetCopier
Copy all (remaining) input rows to the output. If insufficient space exists in the output, does a partial copy, andResultSetCopier.isCopyPending()
will return true.- Specified by:
copyAllRows
in interfaceResultSetCopier
-
isCopyPending
public boolean isCopyPending()Description copied from interface:ResultSetCopier
Helper method to determine if a copy is pending: more rows remain to be copied. If so, start a new output batch, which will finish the copy. Do that before start a new input batch.- Specified by:
isCopyPending
in interfaceResultSetCopier
- Returns:
-
harvest
Description copied from interface:ResultSetCopier
Obtain the output batch. Returned as a vector container since the output will not have a selection vector.- Specified by:
harvest
in interfaceResultSetCopier
- Returns:
- a vector container holding the output batch
-
close
public void close()Description copied from interface:ResultSetCopier
Release resources, including any pending input batch and any non-harvested output batch.- Specified by:
close
in interfaceResultSetCopier
-