aggregation

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 3 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 aggregation implements aggregation functions to statistic a range of values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromFieldValue added in v0.3.0

func FromFieldValue[N Number](fieldValue *modelv1.FieldValue) (N, error)

FromFieldValue transforms modelv1.FieldValue to Number.

func PartialToFieldValues added in v0.10.0

func PartialToFieldValues[N Number](af modelv1.AggregationFunction, p Partial[N]) ([]*modelv1.FieldValue, error)

PartialToFieldValues converts a Partial to field values for wire transport. For MEAN it returns two values (Value/sum first, Count second); for others one value.

func ToFieldValue added in v0.3.0

func ToFieldValue[N Number](value N) (*modelv1.FieldValue, error)

ToFieldValue transforms Number to modelv1.FieldValue.

Types

type Map added in v0.10.0

type Map[N Number] interface {
	In(N)
	Val() N
	Partial() Partial[N]
	Reset()
}

Map accumulates raw values and produces aggregation results. It serves as the local accumulator for raw data points.

func NewMap added in v0.10.0

func NewMap[N Number](af modelv1.AggregationFunction) (Map[N], error)

NewMap returns a Map aggregation function for the given type.

type Number added in v0.3.0

type Number interface {
	~int64 | ~float64
}

Number denotes the supported number types.

type Partial added in v0.10.0

type Partial[N Number] struct {
	Value N
	Count N
}

Partial represents the intermediate result of a Map phase. For most functions only Value is meaningful; for MEAN both Value (sum) and Count are used.

func FieldValuesToPartial added in v0.10.0

func FieldValuesToPartial[N Number](af modelv1.AggregationFunction, fvs []*modelv1.FieldValue) (Partial[N], error)

FieldValuesToPartial converts field values from wire transport to a Partial. For MEAN expects two values (sum, count); for others one value (Count will be zero).

type Reduce added in v0.10.0

type Reduce[N Number] interface {
	Combine(Partial[N])
	Val() N
	Reset()
}

Reduce combines intermediate results from Map phases into a final value.

func NewReduce added in v0.10.0

func NewReduce[N Number](af modelv1.AggregationFunction) (Reduce[N], error)

NewReduce returns a Reduce aggregation function for the given type.

Jump to

Keyboard shortcuts

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