Skip to main content

Module series_execution

Module series_execution 

Source
Expand description

The in-process handover between two adjacent native PromQL operators.

Two native operators pass each other a SeriesFrame record batch today: the producer packs its chunks into one and the consumer unpacks them again, only because [ExecutionPlan::execute] answers a SendableRecordBatchStream. No DataFusion operator stands between them, so the frame is written and read back for nobody: a transport type used for a function call.

SeriesExecutionPlan is that call. A native operator that can answer its chunks as they are implements the trait, and a native consumer that receives one calls SeriesExecutionPlan::execute_series instead of decoding a frame. The chunk is the internal value the operator already holds - a [RawSeriesChunk] read from a region, an EvaluatedChunk a tree settled on its grid, or a StateChunk a Partial folded - so the handover reuses the buffers instead of encoding them. Every content a native node publishes travels this way; there is no second path for one of them to be left on.

What keeps the shortcut structural, rather than a convention an operator has to remember, is that the capability is a type: series_execution_plan answers for the operators this crate implements it on and for nothing else. A plan that produces frames is not one of them - a network exchange, a remote scan, or any node reading a frame it received answers None - so no chunk reaches a consumer across a boundary this way. The question is asked once per input and answered by the input alone: calling execute_series is how a consumer says it reads that input’s chunks, and calling [ExecutionPlan::execute] is how it says it reads its frames. There is no second decision to keep in step with the first.

Which edge this is, and which edge it is not:

  • In process: the two ends are nodes of one plan in one process, and the consumer called execute_series on the operator it was handed as an input. That is the whole of where a chunk can travel.
  • Still bytes: every edge that leaves the process, or reaches a node this crate does not own. A region’s scan and the scan a merge sits on still publish RecordBatches, a remote scan answers frames, and a root output still converts series back into a batch (series_to_record_batch). No chunk is serialized and none is sent anywhere, so nothing about the wire changes here.

Two things the frame path does are not skipped, because they are not about the encoding:

  • The sequence is checked. [SequenceValidator] and [EvaluatedSequenceValidator] are what a frame consumer runs while it decodes; checked_series_stream runs the same validators over the same sequence of chunks, so a producer whose chains are malformed is refused here exactly as it is through a frame. An exported state row has no such chain - its frame consumer runs no cross-row validator either - so there is nothing for that content to skip.
  • The memory is charged for as long as it is held. A producer that merges an identity reserves the bytes it merges into and hands them over with the value (SeriesCharge), so the pool sees them until the consumer drops the chunk that carries them - not until a packer flushed a batch, and not for longer either.

What a consumer records does not change with the representation. The figures a native node keeps are recorded per chunk it was fed, and both paths feed it the producer’s chunks: a frame carries a chunk as a row, and decoding it yields the chunk back. The one figure that can differ is the count of those chunks, and only for a chunk whose field is itself split into segments - a frame row never spans two segments of one field, so such a chunk is one chunk in process and several rows in a frame. Nothing else, and in particular no sample, value or closed-series count, is recorded on one path and not the other.

Structs§

CheckedSeries 🔒
The handover stream, with the frame path’s sequence check in front of the consumer.
HandedSeriesChunk
One chunk handed over in process, and what it is charged to.
SeriesCharge
What one handed chunk is charged to, released when the chunk is.

Enums§

SeriesChunk
One piece of one series, handed from one native operator to the next.

Traits§

SeriesExecutionPlan
A native operator that can hand its output over in-process without encoding a frame.

Functions§

checked_error 🔒
The error a broken chunk sequence is reported as, in the handover’s own error type.
checked_series_stream
chunks with the sequence check the frame path runs, applied to each chunk as it arrives.
series_execution_plan
plan as a native series operator, when it is one.

Type Aliases§

SendableSeriesStream
One partition’s output as internal series, not as an encoded frame.