Skip to content

StreamingCSVTrace

class StreamingCSVTrace : public Trace

Streaming CSV (Comma-Separated Values) file format reader

Uses 4-layer architecture for terabyte-scale trace processing:

Layer 1: Streaming I/O - StreamingChunkReader: C++20 coroutines, 100 MB chunks

Layer 2: Indexing & Caching - SparseIndex: Timestamp → file offset mapping - SignalValueCache: LRU cache with adaptive sizing

Layer 3: Format-Specific Reader - StreamingCSVTrace: Lazy CSV parsing - Support for time-based and signal-based formats - Hierarchical scope support - Format validation

Layer 4: Public API - Trace base class interface - Transparent streaming to users

Memory Model: - Fixed: StreamingChunkReader (100 MB) - Bounded: SparseIndex (~1 MB for 1B timestamps) - Bounded: SignalValueCache (~15 MB typical) - Total: ~130 MB for 1 TB file

Performance: - Query latency: <50 ms (disk) or <1 ms (cached) - Cache hit rate: 95%+ after warming - Memory independent of file size

CSV Format Support: 1. Time-based (default): timestamp,signal1,signal2,... 0,1,0 10,0,1

  1. Signal-based: time,clk,data,valid 0,1,255,0 10,0,128,1

Functions

Name Description
StreamingCSVTrace Constructor for streaming CSV trace tid : Trace identifier filename : Path to CSV file container : Reference trace container chunk_size : Size of I/O chunks (default: 100 MB) cache_entries : Entries per signal in cache (default: 1000)
load Load and parse CSV file header Initializes streaming components
signal_value Get signal value with lazy loading
signal_width Get signal width in bits
contains_signal Check if signal exists
get_all_signals Get all signal names
step Step through time (move to next/previous timestamp) steps : Number of steps (positive=forward, negative=backward) Return : true if step was successful, false if at boundary
get_index Get current time index
set_delimiter Configure CSV parsing
warm_cache Pre-warm cache for frequently accessed signals
get_cache_statistics Get cache statistics
parse_csv_header Parse CSV header row to extract signal names
read_signal_value Parse value changes for a signal at given timestamp
lookup_or_load Cache lookup with LRU eviction
evict_lru Evict least recently used entries from cache
split_csv_line Split CSV line by delimiter
parse_value Parse numeric value from string
infer_width Infer signal width from value

Function Details

StreamingCSVTrace

StreamingCSVTrace(const std::string& tid, const std::string& filename, std::shared_ptr<TraceContainer> container, size_t chunk_size = 100 * 1024 * 1024, size_t cache_entries = 1000)

Constructor for streaming CSV trace

tid
Trace identifier
filename
Path to CSV file
container
Reference trace container
chunk_size
Size of I/O chunks (default: 100 MB)
cache_entries
Entries per signal in cache (default: 1000)

contains_signal

bool contains_signal(const std::string& name) const override

Check if signal exists

evict_lru

void evict_lru(SignalCache& cache)

Evict least recently used entries from cache

get_all_signals

std::vector<std::string> get_all_signals() const override

Get all signal names

get_cache_statistics

std::string get_cache_statistics() const

Get cache statistics

get_index

int get_index() const

Get current time index

infer_width

static int infer_width(int64_t max_value)

Infer signal width from value

load

void load()

Load and parse CSV file header Initializes streaming components

lookup_or_load

Value lookup_or_load(const std::string& name, int64_t timestamp)

Cache lookup with LRU eviction

parse_csv_header

void parse_csv_header()

Parse CSV header row to extract signal names

parse_value

static Value parse_value(const std::string& value)

Parse numeric value from string

read_signal_value

Value read_signal_value(const std::string& name, int64_t timestamp)

Parse value changes for a signal at given timestamp

set_delimiter

void set_delimiter(char delim)

Configure CSV parsing

signal_value

Value signal_value(const std::string& name, int offset = 0, const std::string& scope = "") override

Get signal value with lazy loading

signal_width

int signal_width(const std::string& name) override

Get signal width in bits

split_csv_line

static std::vector<std::string> split_csv_line(const std::string& line, char delim)

Split CSV line by delimiter

step

bool step(int steps = 1) override

Step through time (move to next/previous timestamp)

steps
Number of steps (positive=forward, negative=backward)
Return
true if step was successful, false if at boundary

warm_cache

void warm_cache(const std::vector<std::string>& signal_names)

Pre-warm cache for frequently accessed signals