Expand description
Zero-Copy Iterators - mmap-based Scans
This module provides memory-mapped file access for efficient, zero-copy iteration over large data files.
§Design
┌─────────────────────────────────────────────────────────────────┐
│ Zero-Copy Iterator │
│ │
│ Application OS/Kernel │
│ ┌────────────┐ ┌────────────────────┐ │
│ │ Iterator │ │ Page Cache │ │
│ │ │ │ ┌──────────────┐ │ │
│ │ &[u8] ────┼─────────────────┼─▶│ Data Pages │ │ │
│ │ │ mmap │ └──────────────┘ │ │
│ └────────────┘ │ ↑ │ │
│ │ │ │ │ │
│ │ No copy! │ ┌────┴────┐ │ │
│ ▼ │ │ Disk │ │ │
│ Process data │ └─────────┘ │ │
│ in-place └────────────────────┘ │
│ │
│ Benefits: │
│ • No buffer copies │
│ • OS manages page faults │
│ • Efficient for sequential scans │
│ • Read-ahead by OS │
└─────────────────────────────────────────────────────────────────┘§Safety
Memory-mapped regions can become invalid if the underlying file is modified. This implementation provides:
- Read-only mappings by default
- Length validation
- Guard types for safe access
Structs§
- Block
Iterator - Block-aware iterator that parses block headers
- Filtered
Scan - Scanned region with optional filtering
- Iterator
Stats - Iterator statistics
- Iterator
Stats Snapshot - Mmap
Region - Memory-mapped region
- Parallel
Scan Config - Parallel scan configuration
- Range
Scanner - Range scanner for parallel processing
- Zero
Copy Iterator - Zero-copy iterator over chunks of mapped memory
Functions§
- open_
for_ scan - Open a file for zero-copy scanning
- scan_
file - Create an iterator over a file