Skip to content

StreamingVCDExample

class StreamingVCDExample

@brief Example usage of StreamingChunkReader with VCD file

This demonstrates: 1. Creating a streaming reader 2. Iterating through chunks with C++20 coroutines 3. Parsing VCD headers from chunks 4. Building sparse index during streaming

Key Principles: - Memory stays bounded (one chunk at a time) - Lazy evaluation (data loaded on-demand) - Perfect for terabyte-scale files

Functions

Name Description
example_stream_vcd_header @brief Stream a VCD file and extract header information Demonstrates: - Opening a streaming reader - Processing chunks incrementally - Stopping after header is complete - Reusing coroutine pattern for actual parsing
example_bounded_memory @brief Demonstrate memory-efficient chunk processing Shows how the same memory is reused for each chunk: - Chunk 1: Read 100 MB → Process → Discard - Chunk 2: Read 100 MB → Process → Discard - Memory never exceeds 100 MB This is impossible with load-all approach for 1TB files!
example_memory_comparison @brief Performance comparison: Load-All vs Streaming Demonstrates why streaming is necessary for terabyte files

Function Details

example_bounded_memory

static void example_bounded_memory(const std::string& filename)

@brief Demonstrate memory-efficient chunk processing

Shows how the same memory is reused for each chunk: - Chunk 1: Read 100 MB → Process → Discard - Chunk 2: Read 100 MB → Process → Discard - Memory never exceeds 100 MB

This is impossible with load-all approach for 1TB files!

example_memory_comparison

static void example_memory_comparison()

@brief Performance comparison: Load-All vs Streaming

Demonstrates why streaming is necessary for terabyte files

example_stream_vcd_header

static void example_stream_vcd_header(const std::string& filename)

@brief Stream a VCD file and extract header information

Demonstrates: - Opening a streaming reader - Processing chunks incrementally - Stopping after header is complete - Reusing coroutine pattern for actual parsing