RowIterator

Trait RowIterator 

Source
pub trait RowIterator: Iterator<Item = Result<Row, ExecutorError>> {
    // Required method
    fn schema(&self) -> &CombinedSchema;

    // Provided method
    fn row_size_hint(&self) -> (usize, Option<usize>) { ... }
}
Expand description

Core trait for row-producing iterators in the query execution pipeline

This trait extends the standard Iterator trait with query-specific metadata and methods. All query operators (scans, filters, joins, projections) implement this trait to enable composable, streaming query execution.

§Why not just use Iterator?

While we could use Iterator<Item = Result<Row, ExecutorError>> directly, this trait adds query-specific capabilities:

  • Access to the output schema (for type checking and column resolution)
  • Size hints for query optimization
  • Future: Statistics, cost estimates, etc.

Required Methods§

Source

fn schema(&self) -> &CombinedSchema

Get the schema of rows produced by this iterator

The schema defines the structure and types of columns in output rows. It remains constant throughout iteration and must match the schema of all rows produced.

Provided Methods§

Source

fn row_size_hint(&self) -> (usize, Option<usize>)

Provide a hint about the number of rows this iterator will produce

This follows the same semantics as Iterator::size_hint():

  • Returns (lower_bound, upper_bound)
  • lower_bound is always <= actual count <= upper_bound.unwrap_or(usize::MAX)
  • None for upper_bound means “unknown” or “unbounded”

These hints can be used for:

  • Allocating appropriately-sized buffers
  • Choosing between nested loop vs hash join
  • Query planning and optimization

The default implementation delegates to the underlying Iterator::size_hint()

Trait Implementations§

Source§

impl<'a> RowIterator for Box<dyn RowIterator + 'a>

Source§

fn schema(&self) -> &CombinedSchema

Get the schema of rows produced by this iterator Read more
Source§

fn row_size_hint(&self) -> (usize, Option<usize>)

Provide a hint about the number of rows this iterator will produce Read more

Implementations on Foreign Types§

Source§

impl<'a> RowIterator for Box<dyn RowIterator + 'a>

Implementors§