libtcspc.read_events_from_binary_file¶
- libtcspc.read_events_from_binary_file(event_type, filename, *, start_offset=0, max_length=None, read_granularity_bytes=65536, stop_normally_on_error=False)[source]¶
Build a subgraph that reads events from a binary file and emits them one at a time.
This is a thin convenience composed of
ReadBinaryStreamfollowed byStoporStopWithError(triggered onWarningEvent) andUnbatch. The resulting subgraph has one input named"input"(no input events expected; the subgraph acts as a source) and one output named"output"that emits individual events ofevent_type.- Parameters:
event_type (EventType) – Element type stored in the file. Must be a trivially-typed event.
filename (str or Param[str]) – Path to the input file. May be supplied as a runtime
Param.start_offset (int or Param[int]) – Byte offset within the file at which to start reading. Defaults to
0.max_length (int or Param[int] or None) – Maximum number of bytes to read.
None(the default) means read to end of file. Should be a multiple of the size ofevent_type.read_granularity_bytes (int or Param[int]) – Read chunk size in bytes. Defaults to
65536. Larger reads have less overhead but may pollute CPU caches.stop_normally_on_error (bool) – If
True, treat read errors as a normal end of input, terminating the stream cleanly. IfFalse(the default), a read error raises an exception.
- Returns:
A subgraph with input
"input"and output"output"that emits individual events ofevent_type.- Return type:
See also