StreamingChunkReader
class StreamingChunkReader
@brief Coroutine that streams trace file in fixed-size chunks
Efficiently reads large trace files by yielding data in configurable chunks. Supports C++20 coroutines for lazy evaluation and memory efficiency.
Memory: O(chunk_size) - only current chunk in RAM Typical chunk size: 100 MB For 1TB file: 100 MB peak memory vs 5 TB load-all approach
Usage Example:
Thread Safety: NOT thread-safe. Each reader must be used in a single thread. For multi-threaded access, create separate readers for each thread.
Error Handling: File errors are propagated as exceptions when calling next() or get_chunk().
- See
- SparseIndex for combining with timestamp indexing
- See
- StreamingVCDTrace for trace-format-specific usage
Operators
| Name | Description |
|---|---|
| operator= | Move assignment |
| bool | @brief Implicit boolean conversion Allows using reader in while() conditions: cpp while (reader) { process(reader.get_chunk()); reader.next(); } Return : true if reader has chunks available |
Functions
| Name | Description |
|---|---|
| StreamingChunkReader | Default constructor - creates empty/invalid reader Move constructor |
| ~StreamingChunkReader | Not copyable Destructor - cleans up coroutine |
| has_chunk | @brief Check if reader has more chunks Returns false when all chunks have been read, or when reader is invalid. |
| get_chunk | @brief Get current chunk without advancing Call this after is_valid() or after next() to get the chunk data. |
| next | @brief Advance to next chunk Resumes the coroutine to read and yield the next chunk. |
Operator Details
bool
explicit operator bool() const
@brief Implicit boolean conversion
Allows using reader in while() conditions:
- Return
- true if reader has chunks available
operator=
StreamingChunkReader& operator=(StreamingChunkReader&& other) noexcept
Move assignment
Function Details
StreamingChunkReader
StreamingChunkReader(StreamingChunkReader&& other) noexcept
Default constructor - creates empty/invalid reader Move constructor
get_chunk
TraceChunk& get_chunk()
@brief Get current chunk without advancing
Call this after is_valid() or after next() to get the chunk data.
- Return
- Reference to current TraceChunk @throws std::logic_error if no chunk available @throws propagated file I/O exceptions
has_chunk
bool has_chunk() const
@brief Check if reader has more chunks
Returns false when all chunks have been read, or when reader is invalid.
- Return
- true if more chunks are available
next
void next()
@brief Advance to next chunk
Resumes the coroutine to read and yield the next chunk. Call get_chunk() after next() to access the data.
@throws propagated file I/O exceptions
~StreamingChunkReader
~StreamingChunkReader()
Not copyable Destructor - cleans up coroutine