Expand description
Streaming Iterator Architecture for Scans
This module implements memory-efficient streaming iterators that:
- Use O(k) memory for LIMIT k queries regardless of table size
- Enable zero-copy SSTable reads via mmap
- Support merge iteration over multiple sorted sources (LSM-tree style)
- Provide backpressure to prevent memory exhaustion
§Memory Complexity
Current scan: M = O(N) where N = rows in scan range Streaming: M = O(k + S × log(S)) where k = LIMIT, S = number of sources
For 100M rows with LIMIT 10:
- Current: 10GB allocation (100M × 100 bytes)
- Streaming: ~10KB (10 rows + heap overhead)
Structs§
- Entry
- A key-value entry with timestamp for MVCC
- Filter
Iterator - Filter iterator for predicate pushdown
- Limit
Iterator - Limit iterator wrapper
- Memtable
Iterator - Memtable iterator (in-memory sorted data)
- Merge
Iterator - Merge iterator over multiple sorted sources (LSM-tree style)
- Range
Iterator - Range-bounded iterator wrapper
- Scan
Stats - Scan statistics
- SstBuilder
- Builder for SSTable data (for testing)
- SstIterator
- SSTable iterator (simulated - real impl would use mmap)
- VecIterator
- Vector-based entry iterator for testing and simple cases
Traits§
- Entry
Iterator - Trait for a streaming source of entries
- Iterator
Ext - Extension trait for iterators