consolidators

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BufferSteps is the default number of steps to buffer.
	BufferSteps = 32
)

Variables

This section is empty.

Functions

func TakeLast

func TakeLast(values []ts.Datapoint) float64

TakeLast is a consolidation function which takes the last datapoint.

Types

type ConsolidationFunc

type ConsolidationFunc func(datapoints []ts.Datapoint) float64

ConsolidationFunc consolidates a bunch of datapoints into a single float value.

type SeriesLookbackConsolidator

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

SeriesLookbackConsolidator is a helper for consolidating a full single series. It has some differences with the step consolidator in that it collects points for a single series, and is reset when the next series needs to be consolidated.

func NewSeriesLookbackConsolidator

func NewSeriesLookbackConsolidator(
	lookbackDuration, stepSize time.Duration,
	startTime time.Time,
	fn ConsolidationFunc,
) *SeriesLookbackConsolidator

NewSeriesLookbackConsolidator creates a single value consolidator used for series iteration with a given lookback.

func (*SeriesLookbackConsolidator) AddPoint

func (c *SeriesLookbackConsolidator) AddPoint(
	dp ts.Datapoint,
)

AddPoint adds a datapoint if it's within the valid time period; otherwise drops it silently, which is fine for consolidation.

func (*SeriesLookbackConsolidator) ConsolidateAndMoveToNext

func (c *SeriesLookbackConsolidator) ConsolidateAndMoveToNext() float64

ConsolidateAndMoveToNext consolidates the current values and moves the consolidator to the next given value, purging stale values.

func (*SeriesLookbackConsolidator) Empty

func (c *SeriesLookbackConsolidator) Empty() bool

Empty returns true if there are no datapoints in the consolidator. It is used to let consumers of the consolidators shortcircuit logic.

func (*SeriesLookbackConsolidator) Reset

func (c *SeriesLookbackConsolidator) Reset(
	startTime time.Time,
)

Reset purges all points from the consolidator. This should be called when moving to the next series to consolidate.

type StepCollector added in v0.6.0

type StepCollector interface {
	// AddPoint adds a datapoint to the current step it's within the valid time
	// period; otherwise drops it silently, which is fine for consolidation.
	AddPoint(ts.Datapoint)
	// BufferStep computes the currently collected step values.
	BufferStep()
	// BufferStepCount gives the number of remaining buffer steps.
	BufferStepCount() int
}

StepCollector is implemented by any accumulators or consolidators working on stepwise iteration.

type StepLookbackAccumulator added in v0.6.0

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

StepLookbackAccumulator is a helper for accumulating series in a step-wise fashion. It takes a 'step' of values, which represents a vertical slice of time across a list of series, and accumulates them when a valid step has been reached.

func NewStepLookbackAccumulator added in v0.6.0

func NewStepLookbackAccumulator(
	lookbackDuration, stepSize time.Duration,
	startTime time.Time,
) *StepLookbackAccumulator

NewStepLookbackAccumulator creates an accumulator used for step iteration across a series list with a given lookback.

func (*StepLookbackAccumulator) AccumulateAndMoveToNext added in v0.6.0

func (c *StepLookbackAccumulator) AccumulateAndMoveToNext() []xts.Datapoint

AccumulateAndMoveToNext consolidates the current values and moves the consolidator to the next given value, purging stale values.

func (*StepLookbackAccumulator) AddPoint added in v0.11.0

func (c *StepLookbackAccumulator) AddPoint(dp ts.Datapoint)

AddPoint adds a datapoint to a given step if it's within the valid time period; otherwise drops it silently, which is fine for accumulation.

func (*StepLookbackAccumulator) BufferStep added in v0.11.0

func (c *StepLookbackAccumulator) BufferStep()

func (*StepLookbackAccumulator) BufferStepCount added in v0.11.0

func (c *StepLookbackAccumulator) BufferStepCount() int

type StepLookbackConsolidator

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

StepLookbackConsolidator is a helper for consolidating series in a step-wise fashion. It takes a 'step' of values, which represents a vertical slice of time across a list of series, and consolidates when a valid step has been reached.

func NewStepLookbackConsolidator

func NewStepLookbackConsolidator(
	lookbackDuration, stepSize time.Duration,
	startTime time.Time,
	fn ConsolidationFunc,
) *StepLookbackConsolidator

NewStepLookbackConsolidator creates a multivalue consolidator used for step iteration across a series list with a given lookback.

func (*StepLookbackConsolidator) AddPoint added in v0.11.0

func (c *StepLookbackConsolidator) AddPoint(dp ts.Datapoint)

AddPoint adds a datapoint to a given step if it's within the valid time period; otherwise drops it silently, which is fine for consolidation.

func (*StepLookbackConsolidator) BufferStep added in v0.11.0

func (c *StepLookbackConsolidator) BufferStep()

func (*StepLookbackConsolidator) BufferStepCount added in v0.11.0

func (c *StepLookbackConsolidator) BufferStepCount() int

func (*StepLookbackConsolidator) ConsolidateAndMoveToNext

func (c *StepLookbackConsolidator) ConsolidateAndMoveToNext() float64

ConsolidateAndMoveToNext consolidates the current values and moves the consolidator to the next given value, purging stale values.

Jump to

Keyboard shortcuts

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