dataset

package
v2.0.0-beta2.0...-6ef21df Latest Latest
Warning

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

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

Documentation

Overview

Package dataset defines the interface for managing time seres objects and provides time range manipulation capabilities

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalDataSet

func MarshalDataSet(ts timeseries.Timeseries, rlo *timeseries.RequestOptions, status int) ([]byte, error)

MarshalDataSet marshals the dataset into a msgpack-formatted byte slice

func UnmarshalDataSet

func UnmarshalDataSet(b []byte, trq *timeseries.TimeRangeQuery) (timeseries.Timeseries, error)

UnmarshalDataSet unmarshals the dataset from a msgpack-formatted byte slice

Types

type DataSet

type DataSet struct {
	// Status is the optional status indicator for the DataSet
	Status string `msg:"status"`
	// ExtentList is the list of Extents (time ranges) represented in the Results
	ExtentList timeseries.ExtentList `msg:"extent_list"`
	// Results is the list of type Result. Each Result represents information about a
	// different statement in the source query for this DataSet
	Results []*Result `msg:"results"`
	// UpdateLock is used to synchronize updates to the DataSet
	UpdateLock sync.Mutex `msg:"-"`
	// Error is a container for any DataSet-level Errors
	Error string `msg:"error"`
	// ErrorType describes the type for any DataSet-level Errors
	ErrorType string `msg:"errorType"`
	// Warnings is a container for any DataSet-level Warnings
	Warnings []string `msg:"warnings"`
	// TimeRangeQuery is the trq associated with the Timeseries
	TimeRangeQuery *timeseries.TimeRangeQuery `msg:"trq"`
	// VolatileExtents is the list extents in the dataset that should be refreshed
	// on the next request to the Origin
	VolatileExtentList timeseries.ExtentList `msg:"volatile_extents"`
	// Sorter is the DataSet's Sort function, which defaults to DefaultSort
	Sorter func() `msg:"-"`
	// Merger is the DataSet's Merge function, which defaults to DefaultMerge
	Merger func(sortSeries bool, ts ...timeseries.Timeseries) `msg:"-"`
	// SizeCropper is the DataSet's CropToSize function, which defaults to DefaultSizeCropper
	SizeCropper func(int, time.Time, timeseries.Extent) `msg:"-"`
	// RangeCropper is the DataSet's CropToRange function, which defaults to DefaultRangeCropper
	RangeCropper func(timeseries.Extent) `msg:"-"`
}

DataSet is the Common Time Series Format that Trickster uses to accelerate most of its supported TSDB backends DataSet conforms to the Timeseries interface

func (*DataSet) Clone

func (ds *DataSet) Clone() timeseries.Timeseries

Clone returns a new, perfect copy of the DataSet

func (*DataSet) CropToRange

func (ds *DataSet) CropToRange(e timeseries.Extent)

CropToRange reduces the DataSet down to timestamps contained within the provided Extents (inclusive). CropToRange assumes the base DataSet is already sorted, and will corrupt an unsorted DataSet

func (*DataSet) CropToSize

func (ds *DataSet) CropToSize(sz int, t time.Time, lur timeseries.Extent)

CropToSize reduces the number of elements in the Timeseries to the provided count, by evicting elements using a least-recently-used methodology. The time parameter limits the upper extent to the provided time, in order to support backfill tolerance

func (*DataSet) CroppedClone

func (ds *DataSet) CroppedClone(e timeseries.Extent) timeseries.Timeseries

CroppedClone returns a new, perfect copy of the DataSet, efficiently cropped to the provided Extent. CroppedClone assumes the DataSet is sorted.

func (*DataSet) DecodeMsg

func (z *DataSet) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*DataSet) DefaultMerger

func (ds *DataSet) DefaultMerger(sortSeries bool, collection ...timeseries.Timeseries)

DefaultMerger is the default Merger function

func (*DataSet) DefaultRangeCropper

func (ds *DataSet) DefaultRangeCropper(e timeseries.Extent)

DefaultRangeCropper is the default RangeCropper Function

func (*DataSet) DefaultSizeCropper

func (ds *DataSet) DefaultSizeCropper(sz int, t time.Time, lur timeseries.Extent)

DefaultSizeCropper is the default SizeCropper Function

func (*DataSet) EncodeMsg

func (z *DataSet) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*DataSet) Extents

func (ds *DataSet) Extents() timeseries.ExtentList

Extents returns the DataSet's ExentList

func (*DataSet) InjectTags

func (ds *DataSet) InjectTags(tags Tags)

InjectTags injects the provided tags into all series in all results in the Dataset in an insert-or-update fashion

func (*DataSet) MarshalMsg

func (z *DataSet) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*DataSet) Merge

func (ds *DataSet) Merge(sortSeries bool, collection ...timeseries.Timeseries)

Merge merges the provided Timeseries list into the base DataSet (in the order provided) and optionally sorts the merged DataSet This implementation ignores any Timeseries that are not of type *DataSet

func (*DataSet) Msgsize

func (z *DataSet) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*DataSet) SeriesCount

func (ds *DataSet) SeriesCount() int

SeriesCount returns the count of all Series across all Results in the DataSet

func (*DataSet) SetExtents

func (ds *DataSet) SetExtents(el timeseries.ExtentList)

SetExtents overwrites a DataSet's known extents with the provided extent list

func (*DataSet) SetTimeRangeQuery

func (ds *DataSet) SetTimeRangeQuery(trq *timeseries.TimeRangeQuery)

SetTimeRangeQuery sets the TimeRangeQuery for the DataSet

func (*DataSet) SetVolatileExtents

func (ds *DataSet) SetVolatileExtents(e timeseries.ExtentList)

SetVolatileExtents sets the list of time Extents in the dataset that should be re-fetched

func (*DataSet) Size

func (ds *DataSet) Size() int64

Size returns the memory utilization in bytes of the DataSet

func (*DataSet) Sort

func (ds *DataSet) Sort()

Sort sorts all Values in each Series chronologically by their timestamp Sorting is efficiently baked into DataSet.Merge(), therefore this interface function is unused unless overridden

func (*DataSet) Step

func (ds *DataSet) Step() time.Duration

Step returns the step for the DataSet

func (*DataSet) TimestampCount

func (ds *DataSet) TimestampCount() int64

TimestampCount returns the count of unique timestamps across all series in the DataSet

func (*DataSet) UnmarshalMsg

func (z *DataSet) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

func (*DataSet) ValueCount

func (ds *DataSet) ValueCount() int64

ValueCount returns the count of all values across all Series in the DataSet

func (*DataSet) VolatileExtents

func (ds *DataSet) VolatileExtents() timeseries.ExtentList

VolatileExtents returns the list of time Extents in the dataset that should be re-fetched

type Hash

type Hash uint64

Hash is a numeric value representing a calculated hash

func (*Hash) DecodeMsg

func (z *Hash) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (Hash) EncodeMsg

func (z Hash) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Hash) MarshalMsg

func (z Hash) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (Hash) Msgsize

func (z Hash) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Hash) UnmarshalMsg

func (z *Hash) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Hashes

type Hashes []Hash

Hashes is a slice of type Hash

func (*Hashes) DecodeMsg

func (z *Hashes) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (Hashes) EncodeMsg

func (z Hashes) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Hashes) MarshalMsg

func (z Hashes) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (Hashes) Msgsize

func (z Hashes) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Hashes) UnmarshalMsg

func (z *Hashes) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Marshaler

type Marshaler func(*DataSet, *timeseries.RequestOptions, int, io.Writer) error

Marshaler is a function that serializes the provided DataSet into a byte slice

type Point

type Point struct {
	Epoch  epoch.Epoch   `msg:"epoch"`
	Size   int           `msg:"size"`
	Values []interface{} `msg:"values"`
}

Point represents a timeseries data point

func (*Point) Clone

func (p *Point) Clone() Point

Clone returns a perfect copy of the Point

func (*Point) DecodeMsg

func (z *Point) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Point) EncodeMsg

func (z *Point) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Point) MarshalMsg

func (z *Point) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Point) Msgsize

func (z *Point) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Point) UnmarshalMsg

func (z *Point) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Points

type Points []Point

Points is a slice of type *Point

func (Points) Clone

func (p Points) Clone() Points

Clone returns a perfect copy of the Points

func (Points) CloneRange

func (p Points) CloneRange(start, end int) Points

CloneRange returns a perfect copy of the Points, cloning only the points in the provided index range (upper-bound exclusive)

func (*Points) DecodeMsg

func (z *Points) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (Points) EncodeMsg

func (z Points) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Points) Len

func (p Points) Len() int

Len returns the length of a slice of time series data points

func (Points) Less

func (p Points) Less(i, j int) bool

Less returns true if i comes before j

func (Points) MarshalMsg

func (z Points) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (Points) Msgsize

func (z Points) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (Points) Size

func (p Points) Size() int64

Size returns the memory utilization of the Points in bytes

func (Points) Swap

func (p Points) Swap(i, j int)

Swap modifies a slice of time series data points by swapping the values in indexes i and j

func (*Points) UnmarshalMsg

func (z *Points) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Result

type Result struct {
	// StatementID represents the ID of the statement for this result. This field may not be
	// used by all tsdb implementations
	StatementID int `msg:"statement_id"`
	// Error represents a statement-level error
	Error string `msg:"error"`
	// SeriesList is an ordered list of the Series in this result
	SeriesList []*Series `msg:"series"`
}

Result represents the results of a single query statement in the DataSet

func (*Result) Clone

func (r *Result) Clone() *Result

Clone returns an exact copy of the Result

func (*Result) DecodeMsg

func (z *Result) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Result) EncodeMsg

func (z *Result) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Result) Hashes

func (r *Result) Hashes() Hashes

Hashes returns the ordered list of Hashes for the SeriesList in the Result

func (*Result) MarshalMsg

func (z *Result) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Result) Msgsize

func (z *Result) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Result) Size

func (r *Result) Size() int64

Size returns the size of the Result in bytes

func (*Result) String

func (r *Result) String() string

func (*Result) UnmarshalMsg

func (z *Result) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type ResultsLookup

type ResultsLookup map[int]*Result

ResultsLookup is a map of Results searchable by the Statement ID

type Series

type Series struct {
	// Header is the Series Header describing the Series
	Header SeriesHeader `msg:"header"`
	// Points is the list of Points in the Series
	Points Points `msg:"points"`
	// PointSize is the memory utilization of the Points in bytes
	PointSize int64 `msg:"ps"`
}

Series represents a single timeseries in a Result

func (*Series) Clone

func (s *Series) Clone() *Series

Clone returns a perfect, new copy of the Series

func (*Series) DecodeMsg

func (z *Series) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Series) EncodeMsg

func (z *Series) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Series) MarshalMsg

func (z *Series) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Series) Msgsize

func (z *Series) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (Series) Size

func (s Series) Size() int64

Size returns the memory utilization of the Series in bytes

func (*Series) String

func (s *Series) String() string

func (*Series) UnmarshalMsg

func (z *Series) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type SeriesHeader

type SeriesHeader struct {
	// Name is the name of the Series
	Name string `msg:"name"`
	// Tags is the map of tags associated with the Series
	Tags Tags `msg:"tags"`
	// FieldsList is the ordered list of fields in the Series
	FieldsList []timeseries.FieldDefinition `msg:"fields"`
	// TimestampIndex is the index of the TimeStamp field in the output when
	// it's time to serialize the DataSet for the wire
	TimestampIndex int `msg:"ti"`
	// QueryStatement is the original query to which this DataSet is associated
	QueryStatement string `msg:"query"`
	// Size is the memory utilization of the Header in bytes
	Size int `msg:"size"`
}

SeriesHeader is the header section of a series, and describes its shape, size, and attributes

func (*SeriesHeader) CalculateHash

func (sh *SeriesHeader) CalculateHash() Hash

CalculateHash sums the FNV64a hash for the Header and stores it to the Hash member

func (*SeriesHeader) CalculateSize

func (sh *SeriesHeader) CalculateSize() int

CalculateSize sets and returns the header size

func (*SeriesHeader) Clone

func (sh *SeriesHeader) Clone() SeriesHeader

Clone returns a perfect, new copy of the SeriesHeader

func (*SeriesHeader) DecodeMsg

func (z *SeriesHeader) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*SeriesHeader) EncodeMsg

func (z *SeriesHeader) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*SeriesHeader) MarshalMsg

func (z *SeriesHeader) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*SeriesHeader) Msgsize

func (z *SeriesHeader) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*SeriesHeader) String

func (sh *SeriesHeader) String() string

func (*SeriesHeader) UnmarshalMsg

func (z *SeriesHeader) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type SeriesList

type SeriesList []*Series

SeriesList is an ordered list of Series

func (SeriesList) Equal

func (sl SeriesList) Equal(sl2 SeriesList) bool

Equal returns true if the slices contain identical values in the identical order

func (SeriesList) String

func (sl SeriesList) String() string

type SeriesLookup

type SeriesLookup map[SeriesLookupKey]*Series

SeriesLookup is a map of Series searchable by Series Header Hash

type SeriesLookupKey

type SeriesLookupKey struct {
	StatementID int
	Hash        Hash
}

SeriesLookupKey is the key for a SeriesLookup, consisting of a Result.StatementID and a Series.Hash

func (*SeriesLookupKey) DecodeMsg

func (z *SeriesLookupKey) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (SeriesLookupKey) EncodeMsg

func (z SeriesLookupKey) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (SeriesLookupKey) MarshalMsg

func (z SeriesLookupKey) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (SeriesLookupKey) Msgsize

func (z SeriesLookupKey) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*SeriesLookupKey) UnmarshalMsg

func (z *SeriesLookupKey) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Tags

type Tags map[string]string

Tags is a key/value pair associated with a Series to scope the cardinality of the DataSet

func (Tags) Clone

func (t Tags) Clone() Tags

Clone returns an exact copy of the Tags

func (*Tags) DecodeMsg

func (z *Tags) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (Tags) EncodeMsg

func (z Tags) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Tags) JSON

func (t Tags) JSON() string

JSON returns a string representation of the Tags as a JSON object

func (Tags) KVP

func (t Tags) KVP() string

KVP returns a string representation of the Tags as "key"="value","key2"="value2"

func (Tags) Keys

func (t Tags) Keys() []string

Keys returns a string-sorted list of the Tags's keys

func (Tags) MarshalMsg

func (z Tags) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (Tags) Merge

func (t Tags) Merge(t2 Tags)

Merge merges the provided tags into the subject tags, replacing any duplicate tag names

func (Tags) Msgsize

func (z Tags) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (Tags) Size

func (t Tags) Size() int

Size returns the byte size of the Tags

func (Tags) String

func (t Tags) String() string

String returns a string representation of the Tags

func (Tags) StringsWithSep

func (t Tags) StringsWithSep(sep1, sep2 string) string

StringsWithSep returns a string representation of the Tags with the provided key/value separator

func (*Tags) UnmarshalMsg

func (z *Tags) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

Jump to

Keyboard shortcuts

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