Skip to main content

Module frame

Module frame 

Source
Expand description

One Arrow frame family for raw and evaluated series chunks.

A frame carries the same thing whichever sample shape it holds: one row per chunk of one series, with that series’ identity, its finality, its time axis, and one column of samples per logical field. Field names preserve the logical series schema in order. What varies is declared rather than inferred, because the receiver of a frame has no scanner, region, or planning context to infer it from:

ContentIdentityTimeProducer
rawkeytimestampsa storage raw-series scan
rawexplicittimestampsa raw input whose labels are already decoded
evaluatedexplicitgrid_spansa compute node’s evaluated output

Any other combination is rejected here, because no producer can mean it: an evaluated value’s labels may be rewritten by the computation that produced it, so an evaluated frame cannot claim a storage key as its identity, and raw samples have no evaluation grid to be addressed on.

Packing accumulates bounded multi-row batches: SeriesFrameCursor walks one validated chunk and SeriesFrameBuilder emits rows directly as Arrow arrays once a row or estimated byte bound is reached. Decoding reuses one prepared schema per stream through SeriesFrameDecoder. Column layout, metadata, and wire strings stay on the single v1 contract. Raw frames may also declare greptime.series.ordering=interleaved; older readers that do not recognize this ordering reject it. A key-encoded frame declares a versioned LabelDecodeSpec so its labels can be decoded from the received schema alone, and an evaluated frame declares its GridSpec once instead of repeating timestamps.

§Label decode description versioning

The description is one greptime.series.label_decode metadata entry, and remote plans compare greptime.series.* metadata as exact text, byte for byte: a frontend and a datanode that write different text for the same labels disagree about the schema, and the query fails instead of falling back. The rules that follow from that are:

  • A reader rejects a version it does not implement, rather than guessing. This module writes and reads LABEL_DECODE_VERSION only.
  • LABEL_DECODE_VERSION covers the whole text, including each key column’s LabelDecodeColumn::physical_type. That field is a ConcreteDataType, so the text embeds ConcreteDataType’s serde shape: it is not spelled here, and a change in that type’s serialization does alter this text. What keeps such a change from going unnoticed is the frozen fixture tests/compatibility/wire/raw_series_label_decode/v1_physical_types.json, which records the text of every datatype variant and fails the crate’s tests when any of them is serialized differently.
  • Any change to the shape of this text — a renamed or added field, a different ConcreteDataType spelling, a different logical_tags order — is a breaking change at the same version, because it makes two nodes of different builds disagree. Such a change must bump LABEL_DECODE_VERSION and update that fixture with it.
  • The text is canonical: LabelDecodeSpec::canonicalize fixes the only part whose order carries no meaning, so equal labels always write equal bytes.

Deployment rule: during a rolling upgrade a frame may carry a version the receiving node does not implement, and a byte-for-byte schema comparison may fail for that reason alone. The intended behaviour is that such a mismatch disables the native series path at planning time and falls back to the generic path, instead of failing the query at execution.

TODO(narthex): implement that planning-time fallback. No planner reads raw_series_frame_label_decode to decide support today, so a version or text mismatch currently surfaces as an execution-time error from the raw-frame decode or the remote schema comparison.

Structs§

EvaluatedWalk 🔒
The walk state of one evaluated chunk.
FrameRow 🔒
One pending output row: one chunk’s identity, finality, time slice, and one dense sample slice per field, with its checked encoded-size measure.
FrameShape 🔒
The two declarations the encoder and decoder dispatch on.
LabelDecodeColumn
One ordered key column needed to decode key-encoded labels.
LabelDecodeSpec
Versioned, self-contained description of how to decode key-encoded labels.
LabelDecodeTag
One logical tag name bound to a primary-key column.
RawFieldColumns 🔒
One raw field’s payload columns, borrowed and downcast once per batch.
RawRow 🔒
One decoded raw row, before its chunk is built.
RawWalk 🔒
The walk state of one raw chunk.
SeriesFrameBuilder
Bounded multi-row builder for finite series frame batches.
SeriesFrameCursor
One validated chunk walked into a bounded builder, one row at a time.
SeriesFrameDeclaration
A frame schema’s reserved declarations, parsed and cross-checked.
SeriesFrameDecoder
Reuses one prepared frame schema while decoding all batches of a stream.
StateFrameRow
One decoded state row retaining Arrow handles for its per-field state columns.
StateRowLayout
The Arrow layout the state rows of one publication are encoded against.
StateWalk 🔒

Enums§

ChunkWalk 🔒
Where a cursor is in the chunk it walks.
FrameContent
What one frame’s rows hold.
FrameLabelMode
How a frame names the series of its rows.
LabelDecodeEncoding
Primary-key encoding of the labels a key-encoded frame carries.
RowPayload 🔒
RowTime 🔒
How one row addresses the time of its samples.

Constants§

AGGREGATE_COMPONENTS 🔒
Metadata key listing the accumulator components a state frame carries, in column order.
AGGREGATE_KIND 🔒
Metadata key naming the aggregate whose accumulator a state frame carries.
CONTENT 🔒
FIELD_CHARGE 🔒
Per-field charge for the payload struct, nested list and validity overhead.
FRAME_LAYOUT_VERSION
The layout marker every frame this engine writes carries.
GRID 🔒
HISTOGRAM_LIST_WIDTHS 🔒
Item widths of histogram table list columns 7..=13, in that order.
HISTOGRAM_ROW_CHARGE 🔒
Conservative per-table-row charge: the fixed fourteen-column histogram schema has seven primitive columns plus seven list columns whose item widths are HISTOGRAM_LIST_WIDTHS.
HISTOGRAM_TABLE_CHARGE 🔒
Fixed per-histogram charge for the seven list columns’ offset and validity overhead.
LABELS 🔒
LABEL_DECODE 🔒
Metadata key of the versioned label decode description carried by key-encoded frames.
LABEL_DECODE_VERSION
Version of the label decode description this revision writes and reads.
LAYOUT 🔒
ORDERING 🔒
Metadata key of the producer ordering carried by a complete frame declaration.
RESERVED_KEYS 🔒
Every greptime.series.* key a frame this revision writes may carry.
ROW_CHARGE 🔒
Per-row charge for key/time/nullable overhead shared by every row.
SPAN_CHARGE 🔒
Per-span charge for the two 64-bit coordinates one grid span carries.
TIME 🔒

Functions§

add_checked 🔒
aggregate_state_frame_schema
Builds an aggregate state frame schema with explicit labels and a declared grid.
arrow 🔒
assemble_frame_batch 🔒
Builds the batch from the parts every content shares: the key, finality, time and field columns, plus the labels an explicit frame carries.
binary_array 🔒
Row-level binary keys.
binary_slice 🔒
bitmap_bytes 🔒
checked_offset 🔒
compact_histogram 🔒
down 🔒
empty_histogram 🔒
A histogram with no buckets: what an absent state position holds under the shared mask.
empty_histogram_table 🔒
encode_rows 🔒
Encodes buffered rows as one batch with direct N-row Arrow array construction.
encode_state_fields 🔒
The fields column of a state frame: one list per row, one item per carried position.
err 🔒
float_charge 🔒
Float values plus their validity bitmap.
grid_text 🔒
The canonical greptime.series.grid text of one grid.
histogram_array_charge 🔒
Bytes a histogram table holds: one row’s fixed part per histogram plus every bucket, span and custom bound its list columns carry, so a layout with more buckets is charged more.
histogram_charge 🔒
Reference indices plus their bitmap and the full referenced histogram table.
histogram_table_charge 🔒
list_array 🔒
list_range 🔒
The (start, len) window of one list slot in its child array.
materialize_parts 🔒
Materializes one list child: a single constituent is cloned to keep its buffers shared.
measure_row 🔒
missing_state_component 🔒
mul_checked 🔒
offset_buffer 🔒
pack_raw_series_chunk
Packs one raw chunk, retaining the Vec<RecordBatch> compatibility signature.
parse_grid 🔒
Parses one greptime.series.grid text back into a validated, deferrable grid.
positions_to_spans 🔒
raw_field_columns 🔒
Downcasts every field column of a raw frame’s fields struct once.
raw_series_frame_schema
Builds the typed schema for a raw frame, refusing a series schema with an evaluation grid.
reject_nulls 🔒
Rejects nulls in the [start, start + len) window of one child column.
sample_charge 🔒
sample_charges 🔒
sample_range_growth 🔒
Measures the added dense positions without slicing Arrow arrays or rescanning histogram tables.
segment 🔒
The next dense segment of one field, or an error when the walk left the segment list.
series_frame_label_decode
Recovers the label decode description a frame schema declares.
series_frame_schema
Builds the one frame schema family: raw or evaluated, keyed or explicit.
state_bool 🔒
state_charges 🔒
state_field 🔒
The states one field of a state row carries, in the row’s own position order.
state_float 🔒
state_histogram 🔒
state_payload 🔒
Reads one present position’s state as the payload family its kind keeps.
state_payload_charge 🔒
Bytes one position’s state holds.
struct_array 🔒
unpack_raw_series_frame
Decodes all rows of one raw frame; any malformed row makes the entire call fail.
validate_ordering 🔒
validity 🔒