frame

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package frame binds the shared vec columnar frame codec (pkg/query/vectorized/frame) to the measure engine. It supplies measure's frame signature, wire version and role/type numbering; the byte layout is the shared base's. It is the non-proto, vec-native columnar binary frame carried as the SendResponse.body for TopicInternalMeasureQuery under the G9f throughout-vec design.

Wire layout (version 4, the only version measure speaks):

off  len       field            description
---  --------  ---------------  ---------------------------------------------
  0  4         Magic            fixed [0x00,'V','F','R'] — first byte 0x00
                                forces a proto.Unmarshal of a frame body into
                                *measurev1.InternalQueryResponse{} to return
                                a non-nil error deterministically.
  4  1         WireVersion      4.
  5  uvarint   NumRows          number of (active) rows.
  ?  uvarint   NumCols          number of column blocks.
  ?  ...       Columns          NumCols column blocks, in schema order.

Each column block carries role+type discriminators, the column name, a tag family name (empty for non-RoleTag columns), a validity bitmap and a type-specific data section: each column sends its validity, offsets and value buffers as they sit in memory, padded to 8 bytes, so the receiver builds columns by slicing the message (see the shared base's columnar.go for the byte layout).

Data nodes always emit version 4 and a liaison accepts only version 4. BanyanDB 0.12 does not support rolling or mixed-version upgrades, so there is no negotiation and no row-oriented fallback: a frame of any other version fails with ErrBadVersion.

Index

Constants

View Source
const MagicLen = baseframe.MagicLen

MagicLen is the length of Magic in bytes.

View Source
const MinHeaderLen = baseframe.MinHeaderLen

MinHeaderLen is the smallest possible frame header — 4 magic bytes, 1 version byte, and the minimal 1-byte uvarint encodings of NumRows=0 and NumCols=0.

View Source
const WireVersion uint8 = 4

WireVersion is the columnar frame format version, the only one measure emits and accepts. A decoder rejects a frame of any other version with ErrBadVersion rather than misreading it.

Variables

View Source
var (
	// ErrTruncated signals a frame whose length is below the minimum header
	// length, or whose declared lengths run past the buffer.
	ErrTruncated = baseframe.ErrTruncated

	// ErrBadMagic signals a frame whose leading 4 bytes do not match Magic. A
	// flag-off (proto) body received on the raw path fails here loudly.
	ErrBadMagic = baseframe.ErrBadMagic

	// ErrBadVersion signals a frame whose WireVersion byte does not match the
	// WireVersion.
	ErrBadVersion = baseframe.ErrBadVersion

	// ErrUnsupportedColumnType signals that a column whose ColumnType has no
	// wire mapping crossed the codec.
	ErrUnsupportedColumnType = baseframe.ErrUnsupportedColumnType

	// ErrUnsupportedColumnRole signals that a column whose ColumnRole has no
	// wire mapping crossed the codec.
	ErrUnsupportedColumnRole = baseframe.ErrUnsupportedColumnRole
)

Sentinel errors re-exported from the shared base so callers keep using errors.Is against frame.ErrX; the identities are shared across the boundary.

View Source
var Magic = [4]byte{data.RawFrameMagicLeadingByte, 'V', 'F', 'R'}

Magic is the 4-byte prefix every raw measure frame body MUST begin with. The first byte is data.RawFrameMagicLeadingByte (0x00), which decodes as a varint tag for protobuf field number 0 — forcing a flag-off node's proto.Unmarshal of a raw frame body into *measurev1.InternalQueryResponse{} to return a non-nil error (G9f spec Principle 3). The remaining bytes 'V','F','R' are a distinctive signature so a flag-on decoder can recognize a valid frame.

Functions

func Concat added in v0.12.0

func Concat(frames [][]byte, reserve func(int) error) ([]byte, error)

Concat joins columnar frame rows into one frame without materializing their columns. reserve is called with the exact output capacity before allocation.

func Decode

func Decode(b []byte) (*vectorized.RecordBatch, error)

Decode parses a measure raw frame body back into a RecordBatch. A frame of any version other than WireVersion is rejected with ErrBadVersion. The batch borrows the body and pins it through Owners: the caller releases the batch (RecordBatch.ReleaseOwners) when it is done with it, and copies any cell it keeps beyond that.

func Encode

func Encode(b *vectorized.RecordBatch) ([]byte, error)

Encode serializes a measure vec columnar RecordBatch into a raw columnar frame body.

func EncodeWithReservation added in v0.12.0

func EncodeWithReservation(b *vectorized.RecordBatch, reserve func(int) error) ([]byte, error)

EncodeWithReservation reserves the exact output capacity before encoding a frame.

func Inspect added in v0.12.0

func Inspect(body []byte) (baseframe.ColumnarLayout, error)

Inspect validates frame buffers without allocating decoded columns.

func SameSchema added in v0.12.0

func SameSchema(left, right []byte) (bool, error)

SameSchema compares complete wire column layouts without decoding columns.

Types

type Header = baseframe.Header

Header is the parsed frame header (everything up to but not including the first column block).

func ValidateHeader

func ValidateHeader(b []byte) (Header, int, error)

ValidateHeader is the fail-loud preflight a decoder calls before parsing any column data. It rejects a frame whose magic or wire-version does not match this codec, and returns the parsed Header plus the bytes consumed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL