aggregate

package
v0.7.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package aggregate for measure aggregate function.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Arguments

type Arguments[A, B Input] struct {
	// contains filtered or unexported fields
}

Arguments represents the argument array, with one argument or two arguments.

func NewAvgArguments

func NewAvgArguments[A Input](a []A, b []int64) Arguments[A, int64]

NewAvgArguments constructs arguments.

func NewMinArguments

func NewMinArguments[A Input](a []A) Arguments[A, Void]

NewMinArguments constructs arguments.

type Avg

type Avg[A, B Input, R Output] struct {
	// contains filtered or unexported fields
}

Avg calculates the average value of elements.

func (*Avg[A, B, R]) Combine

func (a *Avg[A, B, R]) Combine(arguments Arguments[A, B]) error

Combine takes elements to do the aggregation. Avg uses type parameter A and B.

func (*Avg[A, B, R]) Result

func (a *Avg[A, B, R]) Result() R

Result gives the result for the aggregation.

type Function

type Function[A, B Input, R Output] interface {
	// Combine takes elements to do the aggregation.
	// It uses a two-dimensional array to represent the argument array.
	Combine(arguments Arguments[A, B]) error

	// Result gives the result for the aggregation.
	Result() R
}

Function describes two stages of aggregation.

func NewFunction

func NewFunction[A, B Input, R Output](kind modelv1.MeasureAggregate) (Function[A, B, R], error)

NewFunction constructs the aggregate function with given kind and parameter types.

type Input

type Input interface {
	Void | ~int64 | ~float64
}

Input covers possible types of Function's arguments. It synchronizes with `FieldType` in schema.

type Min

type Min[A, B Input, R Output] struct {
	// contains filtered or unexported fields
}

Min calculates the minimum value of elements.

func (*Min[A, B, R]) Combine

func (m *Min[A, B, R]) Combine(arguments Arguments[A, B]) error

Combine takes elements to do the aggregation. Min uses type parameter A.

func (*Min[A, B, R]) Result

func (m *Min[A, B, R]) Result() R

Result gives the result for the aggregation.

type Output

type Output interface {
	~int64 | ~float64
}

Output covers possible types of Function's return value.

type Void

type Void struct{}

Void type contains nothing. It works as a placeholder for type parameters of `Arguments`.

Jump to

Keyboard shortcuts

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