pub trait Operator: Send {
// Required methods
fn open(&mut self) -> Result<()>;
fn next(&mut self) -> Result<Option<RowRef>>;
fn close(&mut self) -> Result<()>;
fn schema(&self) -> &[ColumnInfo];
fn name(&self) -> &str;
// Provided methods
fn estimated_rows(&self) -> Option<usize> { ... }
fn ordering(&self) -> OrderingProperty { ... }
}Expand description
Volcano-style iterator interface for query operators.
Each operator implements this trait to participate in the streaming execution pipeline. The execution follows the open-next-close pattern:
open()- Initialize the operator (called once)next()- Get the next row (called repeatedly until None)close()- Release resources (called once at end)
§Thread Safety
Operators are Send to allow execution on different threads,
but individual operators are not Sync - they maintain mutable state.
Required Methods§
Sourcefn open(&mut self) -> Result<()>
fn open(&mut self) -> Result<()>
Initialize the operator.
Called once before the first next() call.
This is where child operators should be opened and
any one-time initialization should occur.
Sourcefn next(&mut self) -> Result<Option<RowRef>>
fn next(&mut self) -> Result<Option<RowRef>>
Get the next row from this operator.
Returns:
Ok(Some(row))- A row is availableOk(None)- No more rows (exhausted)Err(e)- An error occurred
After returning None, subsequent calls should continue to return None.
Sourcefn close(&mut self) -> Result<()>
fn close(&mut self) -> Result<()>
Close the operator and release resources.
Called once after all rows have been consumed or when execution is terminated early. Child operators should also be closed.
Sourcefn schema(&self) -> &[ColumnInfo]
fn schema(&self) -> &[ColumnInfo]
Get the schema (column information) for this operator’s output.
Provided Methods§
Sourcefn estimated_rows(&self) -> Option<usize>
fn estimated_rows(&self) -> Option<usize>
Get an estimate of the number of rows this operator will produce.
Returns None if the estimate is not available.
Used by the query planner for cost estimation.
Sourcefn ordering(&self) -> OrderingProperty
fn ordering(&self) -> OrderingProperty
Physical ordering guaranteed by this operator’s output.
Unknown is deliberately fail-closed: an executor must never discover ordering by rescanning the complete output merely to choose an algorithm.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".