use super::RowIterator;
use crate::{errors::ExecutorError, schema::CombinedSchema};
pub struct TableScanIterator {
schema: CombinedSchema,
rows: std::vec::IntoIter<vibesql_storage::Row>,
#[allow(dead_code)]
total_count: usize,
}
impl TableScanIterator {
pub fn new(schema: CombinedSchema, rows: Vec<vibesql_storage::Row>) -> Self {
let total_count = rows.len();
Self { schema, rows: rows.into_iter(), total_count }
}
}
impl Iterator for TableScanIterator {
type Item = Result<vibesql_storage::Row, ExecutorError>;
fn next(&mut self) -> Option<Self::Item> {
self.rows.next().map(Ok)
}
fn size_hint(&self) -> (usize, Option<usize>) {
self.rows.size_hint()
}
}
impl RowIterator for TableScanIterator {
fn schema(&self) -> &CombinedSchema {
&self.schema
}
fn row_size_hint(&self) -> (usize, Option<usize>) {
let (lower, upper) = self.size_hint();
(lower, upper)
}
}