libtcspc.Batch

final class libtcspc.Batch(event_type, *, buffer_provider=None, batch_size=None)[source]

Bases: Node

Processor that groups events into fixed-size buckets.

Collects every batch_size events of event_type into a bucket obtained from the buffer provider, and emits the bucket as a BucketEvent once full. Batching does not perform time-based flushing, so it can introduce arbitrary latency on real-time event streams; for that reason, intermediate buffering of real-time streams is usually unnecessary and inadvisable.

Parameters:
  • event_type (EventType) – The event type to batch. The input event set must consist only of this type.

  • buffer_provider (BucketSource or None) – Source of buckets used to hold each batch. If None, a default RecyclingBucketSource for event_type is used.

  • batch_size (int or Param[int] or None) – Number of events to collect in each bucket. Defaults to 65536.

Notes

Events handled:

  • Events matching event_type: collected into BucketEvent; emitted when the bucket is full.

  • All other event types: rejected at graph build time.

  • End of input: emit any partially-filled bucket, then pass through.

See also

tcspc::batch()

The underlying C++ factory function.