libtcspc.write_events_to_binary_file

libtcspc.write_events_to_binary_file(event_type, filename, *, truncate=False, append=False, batch_size=None, write_granularity_bytes=65536)[source]

Build a subgraph that writes events to a binary file.

This is a thin convenience composed of Batch, ViewAsBytes, and WriteBinaryStream writing to a BinaryFileOutputStream. The resulting subgraph has one input named "input" that accepts individual events of event_type and no outputs (it is a sink).

Parameters:
  • event_type (EventType) – Element type to write to the file. Must be a trivially-typed event.

  • filename (str or Param[str]) – Path to the output file. May be supplied as a runtime Param.

  • truncate (bool or Param[bool]) – If true, truncate the file if it already exists. Defaults to False.

  • append (bool or Param[bool]) – If true, append to the file if it already exists. Defaults to False.

  • batch_size (int or Param[int] or None) – Number of events per batch. None (the default) uses the Batch default.

  • write_granularity_bytes (int or Param[int]) – Write chunk size in bytes. Defaults to 65536. Larger writes have less overhead but may pollute CPU caches.

Returns:

A subgraph with input "input" and no outputs that writes events of event_type to the file.

Return type:

Subgraph

See also

WriteBinaryStream

Lower-level processor that writes byte buckets to an output stream.

Batch

Groups individual events into batches.

ViewAsBytes

Views bucketed events as their in-memory bytes.