cockroach: Index | Files

package testmodel

import ""


Package Files

data.go db.go functions.go

func AggregateAverage Uses

func AggregateAverage(data DataSeries) float64

AggregateAverage returns the average value of the points in the provided data series.

func AggregateFirst Uses

func AggregateFirst(data DataSeries) float64

AggregateFirst returns the first value in the provided data series.

func AggregateLast Uses

func AggregateLast(data DataSeries) float64

AggregateLast returns the last value in the provided data series.

func AggregateMax Uses

func AggregateMax(data DataSeries) float64

AggregateMax returns the maximum value of any point in the provided data series.

func AggregateMin Uses

func AggregateMin(data DataSeries) float64

AggregateMin returns the minimum value of any point in the provided data series.

func AggregateSum Uses

func AggregateSum(data DataSeries) float64

AggregateSum returns the sum value of all points in the provided data series.

func AggregateVariance Uses

func AggregateVariance(data DataSeries) float64

AggregateVariance returns the variance of the provided data series. The returned variance is the sample variance, not the population variance.

func DataSeriesEquivalent Uses

func DataSeriesEquivalent(a, b DataSeries) bool

DataSeriesEquivalent returns true if the provided data series are roughly equivalent. This is useful primarily to work around floating point errors which occur if the order of computation differs between the model and the real system.

type DataSeries Uses

type DataSeries []tspb.TimeSeriesDatapoint

DataSeries represents a series of data points ordered by timestamp.

func (DataSeries) GroupByResolution Uses

func (data DataSeries) GroupByResolution(resolution int64, aggFunc aggFunc) DataSeries

GroupByResolution aggregates data points in the given series into time buckets based on the provided resolution.

func (DataSeries) Len Uses

func (data DataSeries) Len() int

func (DataSeries) Less Uses

func (data DataSeries) Less(i, j int) bool

func (DataSeries) Swap Uses

func (data DataSeries) Swap(i, j int)

func (DataSeries) TimeSlice Uses

func (data DataSeries) TimeSlice(start, end int64) DataSeries

TimeSlice returns the set of the dataPoints from the supplied series with timestamps that fall in the interval [start, end) (not inclusive of end timestamp).

type ModelDB Uses

type ModelDB struct {
    // contains filtered or unexported fields

ModelDB is a purely in-memory model of CockroachDB's time series database, where time series can be stored and queried.

func NewModelDB Uses

func NewModelDB() *ModelDB

NewModelDB instantiates a new ModelDB instance.

func (*ModelDB) Query Uses

func (mdb *ModelDB) Query(
    name string,
    sources []string,
    downsample, agg tspb.TimeSeriesQueryAggregator,
    derivative tspb.TimeSeriesQueryDerivative,
    slabDuration, sampleDuration, start, end, interpolationLimit, now int64,
) DataSeries

Query retrieves aggregated data from the model database in the same way that data is currently queried from CockroachDB's time series database. Each query has a named metric, an optional set of sources, and a number of specified aggregation options:

+ A downsampler function, which is used to group series by resolution + An aggregation function, which is used to group multiples series by timestamp + A derivative option, which transforms the returned series into a rate of change.

Each query has a sample duration (determines the length of the group-by-time interval), a slab duration (used to emulate certain effects of CockroachDB's current time series tests), a start and end time, and an 'interpolation limit' which is a maximum gap size above which missing data is not filled. When fills are performed, linear interpolation is always used.

func (*ModelDB) Record Uses

func (mdb *ModelDB) Record(metricName, dataSource string, data DataSeries)

Record stores the given data series for the supplied metric and data source, merging it with any previously recorded data for the same series.

func (*ModelDB) UniqueSourceCount Uses

func (mdb *ModelDB) UniqueSourceCount() int64

UniqueSourceCount returns the total number of unique data sources that have been encountered by queries.

func (*ModelDB) VisitAllSeries Uses

func (mdb *ModelDB) VisitAllSeries(visitor seriesVisitor)

VisitAllSeries calls the provided visitor function on every recorded series. The visitor function can optionally return a DataSeries which will completely replace the data series present in the model for that series.

func (*ModelDB) VisitSeries Uses

func (mdb *ModelDB) VisitSeries(name string, visitor seriesVisitor)

VisitSeries calls the provided visitor function for all series with the given metric name. The visitor function can optionally return a DataSeries which will completely replace the data series present in the model for that series.

Package testmodel imports 6 packages (graph). Updated 2019-08-10. Refresh now. Tools for package owners.