timeseriescompact

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package timeseriescompact provides types and utilities for working with compact time series data using attribute table references instead of string labels. This format is optimized for efficient merging and aggregation across distributed query backends.

Currently only used for exemplar retrieval. Over time, this package will replace pkg/model/timeseries for all time series queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DedupeRefs

func DedupeRefs(refs []int64) []int64

DedupeRefs removes duplicate refs and returns sorted unique refs.

func IntersectRefs

func IntersectRefs(refSets [][]int64) []int64

IntersectRefs returns the intersection of multiple ref slices.

func MergeExemplars

func MergeExemplars(a, b []*queryv1.Exemplar) []*queryv1.Exemplar

MergeExemplars combines two exemplar lists. For exemplars with the same profileID, it keeps the highest value and intersects attribute refs.

func RangeSeries

func RangeSeries(it iter.Iterator[CompactValue], start, end, step int64) []*queryv1.Series

RangeSeries aggregates compact points into time steps.

func SelectTopExemplars

func SelectTopExemplars(exemplars []*queryv1.Exemplar, n int) []*queryv1.Exemplar

SelectTopExemplars selects the top N exemplars by value.

Types

type Aggregator

type Aggregator struct {
	// contains filtered or unexported fields
}

Aggregator aggregates compact points within a time step.

func (*Aggregator) Add

func (a *Aggregator) Add(ts int64, v *CompactValue)

Add adds a point to the aggregator.

func (*Aggregator) GetAndReset

func (a *Aggregator) GetAndReset() *queryv1.Point

GetAndReset returns the aggregated point and resets the aggregator.

func (*Aggregator) IsEmpty

func (a *Aggregator) IsEmpty() bool

IsEmpty returns true if no data has been added.

func (*Aggregator) Timestamp

func (a *Aggregator) Timestamp() int64

Timestamp returns the current timestamp.

type CompactValue

type CompactValue struct {
	Ts             int64
	SeriesKey      string
	SeriesRefs     []int64
	Value          float64
	AnnotationRefs []int64
	Exemplars      []*queryv1.Exemplar
}

CompactValue represents a single data point during iteration.

type Merger

type Merger struct {
	// contains filtered or unexported fields
}

Merger merges time series reports in compact format.

func NewMerger

func NewMerger() *Merger

NewMerger creates a new compact time series merger.

func (*Merger) BuildAttributeTable

func (m *Merger) BuildAttributeTable() *queryv1.AttributeTable

BuildAttributeTable returns the merged attribute table.

func (*Merger) Iterator

func (m *Merger) Iterator() iter.Iterator[CompactValue]

Iterator returns an iterator over all merged series.

func (*Merger) MergeReport

func (m *Merger) MergeReport(r *queryv1.TimeSeriesCompactReport)

MergeReport adds a report to the merger, remapping attribute refs.

Jump to

Keyboard shortcuts

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