ts

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: May 18, 2019 License: Apache-2.0 Imports: 2 Imported by: 43

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Memset

func Memset(data []float64, value float64)

Memset is a faster way to initialize a float64 array.

BenchmarkMemsetZeroValues-4 1000000 1344 ns/op 0 B/op 0 allocs/op BenchmarkLoopZeroValues-4 500000 3217 ns/op 0 B/op 0 allocs/op BenchmarkMemsetNonZeroValues-4 1000000 1537 ns/op 0 B/op 0 allocs/op BenchmarkLoopNonZeroValues-4 500000 3236 ns/op 0 B/op 0 allocs/op *

func MemsetInt added in v0.4.3

func MemsetInt(data []int, value int)

MemsetInt is a faster way to initialize an int array.

Types

type Datapoint

type Datapoint struct {
	Timestamp time.Time
	Value     float64
}

A Datapoint is a single data value reported at a given time

type Datapoints

type Datapoints []Datapoint

Datapoints is a list of datapoints.

func (Datapoints) AlignToBounds added in v0.4.6

func (d Datapoints) AlignToBounds(
	bounds models.Bounds,
	lookbackDuration time.Duration,
) []Datapoints

AlignToBounds returns values aligned to given bounds. To belong to a step, values should be <= stepTime and not stale.

func (Datapoints) AlignToBoundsNoWriteForward added in v0.6.0

func (d Datapoints) AlignToBoundsNoWriteForward(
	bounds models.Bounds,
	lookbackDuration time.Duration,
) []Datapoints

AlignToBoundsNoWriteForward returns values aligned to the start time and duration, but does not write points forward after aligning them. This differs from AlignToBounds which will write points forwards if no additional values are found in the values, adding an empty point instead.

func (Datapoints) DatapointAt

func (d Datapoints) DatapointAt(n int) Datapoint

DatapointAt returns the value at the nth element.

func (Datapoints) Datapoints added in v0.4.6

func (d Datapoints) Datapoints() []Datapoint

Datapoints returns all the datapoints.

func (Datapoints) Len

func (d Datapoints) Len() int

Len is the length of the array.

func (Datapoints) ValueAt

func (d Datapoints) ValueAt(n int) float64

ValueAt returns the value at the nth element.

func (Datapoints) Values added in v0.4.6

func (d Datapoints) Values() []float64

Values returns the values representation.

type FixedResolutionMutableValues

type FixedResolutionMutableValues interface {
	MutableValues
	Resolution() time.Duration
	StepAtTime(t time.Time) int
	StartTimeForStep(n int) time.Time
	// Time when the series starts
	StartTime() time.Time
}

FixedResolutionMutableValues are mutable values with fixed resolution between steps

func NewFixedStepValues

func NewFixedStepValues(
	resolution time.Duration,
	numSteps int,
	initialValue float64,
	startTime time.Time,
) FixedResolutionMutableValues

NewFixedStepValues returns mutable values with fixed resolution

type MutableValues

type MutableValues interface {
	Values

	// Sets the value at the given entry
	SetValueAt(n int, v float64)
}

MutableValues is the interface for values that can be updated

type Series

type Series struct {
	Tags models.Tags
	// contains filtered or unexported fields
}

Series is the public interface to a block of timeseries values. Each block has a start time, a logical number of steps, and a step size indicating the number of milliseconds represented by each point.

func NewSeries

func NewSeries(name []byte, vals Values, tags models.Tags) *Series

NewSeries creates a new Series at a given start time, backed by the provided values.

func (*Series) Len

func (s *Series) Len() int

Len returns the number of values in the time series. Used for aggregation.

func (*Series) Name

func (s *Series) Name() []byte

Name returns the name of the timeseries block

func (*Series) Resolution added in v0.5.0

func (s *Series) Resolution() time.Duration

Resolution retrieves the resolution for this series.

func (*Series) SetResolution added in v0.5.0

func (s *Series) SetResolution(resolution time.Duration)

SetResolution sets the resolution for this series. Only used for graphite series consolidation logic after the fetch step.

func (*Series) Values

func (s *Series) Values() Values

Values returns the underlying values interface.

type SeriesList

type SeriesList []*Series

SeriesList represents a slice of series pointers.

type Values

type Values interface {
	// Len returns the number of values present
	Len() int

	// ValueAt returns the value at the nth element
	ValueAt(n int) float64

	// DatapointAt returns the datapoint at the nth element
	DatapointAt(n int) Datapoint

	// Datapoints returns all the datapoints
	Datapoints() []Datapoint

	// AlignToBounds returns values aligned to given bounds. To belong to a step,
	// values should be <= stepTime and not stale.
	AlignToBounds(
		bounds models.Bounds,
		lookbackDuration time.Duration,
	) []Datapoints

	// AlignToBoundsNoWriteForward returns values aligned to the start time
	// and duration, but does not write points forward after aligning them. This
	// differs from AlignToBounds which will write points forwards if no
	// additional values are found in the values, adding an empty point instead.
	AlignToBoundsNoWriteForward(
		bounds models.Bounds,
		lookbackDuration time.Duration,
	) []Datapoints
}

Values holds the values for a timeseries. It provides a minimal interface for storing and retrieving values in the series, with Series providing a more convenient interface for applications to build on top of. Values objects are not specific to a given time, allowing them to be pre-allocated, pooled, and re-used across multiple series. There are multiple implementations of Values so that we can optimize storage based on the density of the series.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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