Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document TableFunctionSplitProcessor thread-safety #16955

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import io.trino.spi.connector.ConnectorSplit;

import javax.annotation.Nullable;

/**
* Processes table functions splits, as returned from {@link io.trino.spi.connector.ConnectorSplitManager}
* for a {@link ConnectorTableFunctionHandle}.
Expand All @@ -27,9 +29,12 @@ public interface TableFunctionSplitProcessor
/**
* This method processes a split. It is called multiple times until the whole output for the split is produced.
*
* @param split a {@link ConnectorSplit} representing a subtask.
* @param split a {@link ConnectorSplit} representing a subtask, or {@code null} if a split has already started to be processed,
findepi marked this conversation as resolved.
Show resolved Hide resolved
* and the implementation returned a {@link TableFunctionProcessorState.Processed} with
* {@link TableFunctionProcessorState.Processed#isUsedInput()} being {@code true}.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm - this is interesting contract :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, the states were primarily designed for the TableFunctionDataProcessor.
That processor gets one portion of data at a time, and it declares isUsedInput() when the portion is ingested. When it has ingested all the due data, it gets null until it's finished.
In case of the TableFunctionSplitProcessor, instead of input data, we have a Split. It is presented to the Processor as a single portion of data. If the processor declares isUsedInput(), it gets null in subsequent calls until it's finished.

* @return {@link TableFunctionProcessorState} including the processor's state and optionally a portion of result.
* After the returned state is {@code FINISHED}, the method will not be called again.
* After the returned state is {@code FINISHED}, the method will not be called again for the split currently being processed
* and may be called with a new split.
*/
TableFunctionProcessorState process(ConnectorSplit split);
TableFunctionProcessorState process(@Nullable ConnectorSplit split);
}