identity

package
v0.53.2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 9 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 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.

func EncodeSorted added in v0.50.0

func EncodeSorted(dst []byte, n int, entry func(int, signal.Attributes) series.Entry) []byte

EncodeSorted encodes n identities in ascending ID order, reusing one attribute buffer.

func WriteSorted added in v0.53.1

func WriteSorted(dst io.Writer, n int, entry func(int, signal.Attributes) series.Entry) (int64, error)

WriteSorted streams n sorted identities in the existing format. A buffered dst coalesces records.

Types

This section is empty.

Jump to

Keyboard shortcuts

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