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
- Variables
- func Concat(frames [][]byte, reserve func(int) error) ([]byte, error)
- func Decode(b []byte) (*vectorized.RecordBatch, error)
- func Encode(b *vectorized.RecordBatch) ([]byte, error)
- func EncodeWithReservation(b *vectorized.RecordBatch, reserve func(int) error) ([]byte, error)
- func Inspect(body []byte) (baseframe.ColumnarLayout, error)
- func SameSchema(left, right []byte) (bool, error)
- type Header
Constants ¶
const MagicLen = baseframe.MagicLen
MagicLen is the length of Magic in bytes.
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.
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 ¶
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.
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
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
SameSchema compares complete wire column layouts without decoding columns.