pub trait MorselPlanner: Send + Debug {
// Required method
fn plan(self: Box<Self>) -> Result<Option<MorselPlan>>;
}Expand description
A Morsel Planner is responsible for creating morsels for a given scan.
The MorselPlanner is the unit of I/O. There is only ever a single I/O
outstanding for a specific planner. DataFusion may run
multiple planners in parallel, which corresponds to multiple parallel
I/O requests.
It is not a Rust Stream so that it can explicitly separate CPU bound
work from I/O work.
The design is similar to ParquetPushDecoder: when plan is called, it
should do CPU work to produce the next morsels or discover the next I/O
phase.
Best practice is to spawn I/O in a Tokio task on a separate runtime to ensure that CPU work doesn’t block or slow down I/O work, but this is not strictly required by the API.
Required Methods§
Sourcefn plan(self: Box<Self>) -> Result<Option<MorselPlan>>
fn plan(self: Box<Self>) -> Result<Option<MorselPlan>>
Attempt to plan morsels. This may involve CPU work, such as parsing parquet metadata and evaluating pruning predicates.
It should NOT do any I/O work, such as reading from the file. If I/O is
required, the returned MorselPlan should contain a pending planner
future that the caller polls to drive the I/O work to completion. Once
that future resolves, it yields a planner ready for work.
Note this function is not async to make it explicitly clear that if
I/O is required, it should be done in the returned io_future.
Returns None if the planner has no more work to do.
§Empty Morsel Plans
It may return None, which means no batches will be read from the file
(e.g. due to late-pruning based on statistics).
§Output Ordering
See the comments on MorselPlan for the logical output order.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".