Collect icon

Collect

1 VersionUtility

Buffered accumulator with a boolean flush gate. Each tick pulls one {{type:Bool}} from the gate stream and one {{type:t}} from the value stream; while the gate is true the value is appended to an internal list; on the FIRST tick where the gate goes false, the worker emits the accumulated {{type:[t]}} and resets the buffer.

How it fits

{{type:Bool}}  (gate)   --+
                          +--> {{component:collect}} --> {{type:[t]}}   (emitted on gate-true → false edge)
{{type:t}}     (value)  --+

Pick this when a stream must be sliced into variable-length groups gated by an external boolean — speech-turn end, motion-stopped event, condition-cleared signal — and downstream wants {{type:[t]}} lists rather than the individual {{type:t}} items. {{type:t}} is bound at backend-resolution time and accepts any pipelang type — images, detections, strings, audio frames, structured records.

Typical backends

  • Speech-turn buffer: {{component:detect_voice_activity_silero_vad}} (gate) plus audio chunks -> {{component:collect}} -> downstream transcriber.
  • Filtered window: {{component:filter}} (gate) plus value stream -> {{component:collect}} -> {{component:length}}.
  • Condition-cleared flush: {{component:check_object_distance}} (gate) plus records -> {{component:collect}} -> {{component:flatten}}.
  • Gated batch to a sink: gated value stream -> {{component:collect}} -> {{component:output_json_http}}.

Caveats

  • The two inputs are consumed in lockstep one message per tick (SHIFT_ONE_MESSAGE on each). Rate mismatch back-pressures the slower producer; misaligned cadences pair values with the wrong gate state and silently corrupt the resulting groups.
  • The internal buffer persists across ticks while the gate stays true and is cleared ONLY when the gate goes false AND the worker decides to emit. Container restart is the only other reset path.
  • Emission happens once on the gate-true → false edge. Subsequent false ticks with an empty buffer are silent unless {{param:allow_empty}} is enabled.
  • {{param:allow_empty}} true emits an empty {{type:[t]}} on every false tick even when no values were accumulated — useful for keeping a heartbeat cadence aligned with downstream. {{param:allow_empty}} false suppresses zero-length flushes entirely; downstream sees one list per actual gated run.
  • A false tick that arrives BEFORE any true tick (cold start) is silent unless {{param:allow_empty}} is enabled.
  • The buffer grows unbounded while the gate stays true. There is no max-size guard; pair with a counter or timer if open-ended true runs are possible.
  • Values are moved into the buffer (not copied). Upstream producers must not retain references to the value messages they have emitted.
  • The worker has no notion of time, only of the lockstep tick. A gate that flickers truefalsetrue produces one emission per false tick.

Versions

  • 4be67effdefaultlatestlinux/amd64

    live-test prerelease 2026-05-21T15:00:55Z