vibesql_executor/select/iterator/
scan.rs1use super::RowIterator;
4use crate::{errors::ExecutorError, schema::CombinedSchema};
5
6pub struct TableScanIterator {
22 schema: CombinedSchema,
23 rows: std::vec::IntoIter<vibesql_storage::Row>,
24 #[allow(dead_code)]
25 total_count: usize,
26}
27
28impl TableScanIterator {
29 pub fn new(schema: CombinedSchema, rows: Vec<vibesql_storage::Row>) -> Self {
35 let total_count = rows.len();
36 Self { schema, rows: rows.into_iter(), total_count }
37 }
38}
39
40impl Iterator for TableScanIterator {
41 type Item = Result<vibesql_storage::Row, ExecutorError>;
42
43 fn next(&mut self) -> Option<Self::Item> {
44 self.rows.next().map(Ok)
45 }
46
47 fn size_hint(&self) -> (usize, Option<usize>) {
48 self.rows.size_hint()
49 }
50}
51
52impl RowIterator for TableScanIterator {
53 fn schema(&self) -> &CombinedSchema {
54 &self.schema
55 }
56
57 fn row_size_hint(&self) -> (usize, Option<usize>) {
58 let (lower, upper) = self.size_hint();
59 (lower, upper)
60 }
61}