aggregate

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidAgg

func IsValidAgg(desc string) bool

IsValidAgg returns true if desc is a valid descriptor for an aggregator type.

Types

type Aggregator

type Aggregator interface {
	// Add records a single data point.
	Add(n int64)
	// Result returns the final output of aggregation.
	Result() int64
	// Reset returns the aggregator to its initial state.
	Reset()
}

Aggregator summarizes a set of integer data points to a single number.

func NewFromDescriptor

func NewFromDescriptor(desc string) (Aggregator, error)

NewFromDescriptor returns an aggregator that implements desc. Returns BadDescriptorError if desc cannot be parsed.

type AggregatorFactory

type AggregatorFactory func() Aggregator

AggregatorFactory creates a new Aggregator initialized to zero.

func NewFactoryFromDescriptor

func NewFactoryFromDescriptor(desc string) (AggregatorFactory, error)

NewFactoryFromDescriptor returns an AggregatorFactory that will create Aggregators based on desc. Returns BadDescriptorError if desc is not a valid descriptor.

type BadDescriptorError

type BadDescriptorError string

BadDescriptorError is returned when an aggregator descriptor is malformed

func (BadDescriptorError) Error

func (b BadDescriptorError) Error() string

type KeyAggregator

type KeyAggregator struct {
	// Key is the list of key fields over which we are aggregating.
	Key []string
	// contains filtered or unexported fields
}

KeyAggregator tracks data across all requested event fields for a single key.

func (KeyAggregator) Add

func (ka KeyAggregator) Add(e model.Event)

Add updates all aggregators tracked for this key according to the provided event.

func (*KeyAggregator) Reset

func (ka *KeyAggregator) Reset()

Reset clears all aggregators to their initial state.

func (KeyAggregator) Result

func (ka KeyAggregator) Result() []int64

Result returns the aggregation results for this key, in order of their appearance in the descriptor used to create the KeyAggregatorFactory.

type KeyAggregatorFactory

type KeyAggregatorFactory struct {
	// keyFields is the names of the fields to use as keys: ["key", "size"]
	KeyFields []string

	// AggFields is the names of the fields to aggregate over, in order of display.
	AggFields []string
	// contains filtered or unexported fields
}

KeyAggregatorFactory creates KeyAggregators that all share the same method of aggregation across event fields.

func NewKeyAggregatorFactory

func NewKeyAggregatorFactory(desc string) (KeyAggregatorFactory, error)

NewKeyAggregatorFactory creates a KeyAggregatorFactory. The descriptor should be a comma-separated list of field names (key, size, etc.) and aggregate descriptions (sum(size), p99(latency), etc.).

func (KeyAggregatorFactory) FlatKey

func (f KeyAggregatorFactory) FlatKey(e model.Event) string

FlatKey returns a string key based on the flattened key fields of an event, suitable for use in a map.

func (KeyAggregatorFactory) Key

Key returns a list of strings used together as the composite key for an event.

func (KeyAggregatorFactory) New

func (f KeyAggregatorFactory) New() (ka KeyAggregator)

New creates a new KeyAggregator configured to perform aggregation based on the descriptor used to create this KeyAggregatorFactory.

type Max

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

Max retains the maximum value in the aggregated data.

func (*Max) Add

func (m *Max) Add(n int64)

func (*Max) Reset

func (m *Max) Reset()

func (*Max) Result

func (m *Max) Result() int64

type Mean

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

Mean returns the arithmetic mean of the aggregated data.

func (*Mean) Add

func (m *Mean) Add(n int64)

func (*Mean) Reset

func (m *Mean) Reset()

func (*Mean) Result

func (m *Mean) Result() int64

type Min

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

Min retains the minimum value in the aggregated data.

func (*Min) Add

func (m *Min) Add(n int64)

func (*Min) Reset

func (m *Min) Reset()

func (*Min) Result

func (m *Min) Result() int64

type Percentile

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

Percentile returns the nth percentile sample from the aggregated data.

func NewPercentile

func NewPercentile(quantile float64, maxValue int64) *Percentile

func (*Percentile) Add

func (p *Percentile) Add(n int64)

func (*Percentile) Reset

func (p *Percentile) Reset()

func (*Percentile) Result

func (p *Percentile) Result() int64

type Sum

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

Sum returns the sum of the aggregated data.

func (*Sum) Add

func (s *Sum) Add(n int64)

func (*Sum) Reset

func (s *Sum) Reset()

func (*Sum) Result

func (s *Sum) Result() int64

Jump to

Keyboard shortcuts

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