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