identity

package
v0.45.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package identity is the on-disk form of a part's identity set: the signal.Series of every series the part holds, encoded against a symbol table private to the object.

It is what makes identity **part-scoped**. A whole-set identity object at the engine prefix has to be rewritten whenever the set changes and never shrinks with the data, so identities outlive the samples that named them and a node's resident index spans every series it has ever seen. Scoping identity to the part that holds it makes retention self-cleaning (deleting a part deletes its identities), makes a flush cost what it added rather than what the tenant has, and gives every node — owner or replica — a live identity set derived from its own parts. Prometheus' block index and VictoriaMetrics' per-partition indexDB have the same shape; the duplication of an identity across the parts that share it is the accepted price, folded back by merges.

Layout

[magic "OTID" <4b>][version <1b>]
  section bytes …
[TOC: uvarint count, then per section: kind <1b>, uvarint offset, uvarint length, CRC32C <4b>]
[TOC offset <4b BE>][CRC32C of the TOC <4b>]

Sections are addressed by the trailing table of contents, and the TOC's own offset is the last fixed-width field, so a reader can find it from the object's tail alone — a section can be read by byte range without fetching the whole object, and a section kind added later without breaking a reader (unknown kinds are skipped). Today there are two: the symbol table and the series records.

The object is deliberately **not compressed**: interning already removes the repetition a compressor would find (measured ~3.8× on a churn-shaped set), and a compressed body would defeat the range-addressability the layout exists to preserve.

Index

Constants

This section is empty.

Variables

View Source
var ErrCorrupt = errors.New("identity: corrupt identity object")

ErrCorrupt is returned when an identity object fails to parse. Decoding never panics on malformed input.

Functions

func Count

func Count(data []byte) (int, error)

Count returns the number of identities the object holds, without decoding them.

func Decode

func Decode(data []byte, fn func(id signal.SeriesID, s signal.Series) error) error

Decode calls fn for every identity in data, in ascending id order, stopping at the first error fn returns.

The identities it yields **alias data**: their label bytes point into the object's symbol table, so a caller that keeps one past the call must intern or clone it (the series index does, on Add). That is what makes loading a part's identities allocation-light on the recovery path.

func Encode

func Encode(dst []byte, entries []series.Entry) []byte

Encode appends the identity object for entries to dst. Entries are written in ascending id order (the caller's slice is not modified), matching the part's series-index sidecar so the two can be read positionally later.

Types

This section is empty.

Jump to

Keyboard shortcuts

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