timeseries

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package timeseries 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

This section is empty.

Types

type Extent

type Extent struct {
	Start    time.Time `json:"start"`
	End      time.Time `json:"end"`
	LastUsed time.Time `json:"-"`
}

Extent describes the start and end times for a given range of data

func (*Extent) After

func (e *Extent) After(t time.Time) bool

After returns true if the range of the Extent is completely after the provided time

func (*Extent) EndsAt

func (e *Extent) EndsAt(t time.Time) bool

EndsAt returns true if the t is equal to the Extent's end time

func (*Extent) Includes

func (e *Extent) Includes(t time.Time) bool

Includes returns true if the Extent includes the provided Time

func (*Extent) StartsAt

func (e *Extent) StartsAt(t time.Time) bool

StartsAt returns true if the t is equal to the Extent's start time

func (Extent) String

func (e Extent) String() string

After returns true if the range of the Extent is completely after the provided time

type ExtentList

type ExtentList []Extent

ExtentList is a type of []Extent used for sorting the slice

func (ExtentList) Clone

func (el ExtentList) Clone() ExtentList

Clone returns a true copy of the ExtentList

func (ExtentList) Compress

func (el ExtentList) Compress(step time.Duration) ExtentList

Compress sorts an ExtentList and merges time-adjacent Extents so that the total extent of data is accurately represented in as few Extents as possible

func (ExtentList) Crop

func (el ExtentList) Crop(e Extent) ExtentList

Crop ...

func (ExtentList) InsideOf

func (el ExtentList) InsideOf(e Extent) bool

InsideOf ...

func (ExtentList) Len

func (el ExtentList) Len() int

Len returns the length of a slice of type ExtentList

func (ExtentList) Less

func (el ExtentList) Less(i, j int) bool

Less returns true if element i in the ExtentList comes before j

func (ExtentList) OutsideOf

func (el ExtentList) OutsideOf(e Extent) bool

OutsideOf ...

func (ExtentList) Size added in v1.0.4

func (el ExtentList) Size() int

Size returns the approximate memory utilization in bytes of the timeseries

func (ExtentList) String

func (el ExtentList) String() string

String returns a string representation of the extentlist in the format startEpochSec1-endEpochSec1;startEpochSec2-endEpochSec2

func (ExtentList) Swap

func (el ExtentList) Swap(i, j int)

Swap modifies an ExtentList by swapping the values in indexes i and j

type ExtentListLRU

type ExtentListLRU []Extent

ExtentListLRU is a type of []Extent used for sorting the slice by LRU

func (ExtentListLRU) Clone

func (el ExtentListLRU) Clone() ExtentListLRU

Clone returns a true copy of the ExtentListLRU

func (ExtentListLRU) Len

func (el ExtentListLRU) Len() int

Len returns the length of an slice of type ExtentListLRU

func (ExtentListLRU) Less

func (el ExtentListLRU) Less(i, j int) bool

Less returns true if element i in the ExtentListLRU comes before j

func (ExtentListLRU) String

func (el ExtentListLRU) String() string

func (ExtentListLRU) Swap

func (el ExtentListLRU) Swap(i, j int)

Swap modifies an ExtentListLRU by swapping the values in indexes i and j

func (ExtentListLRU) UpdateLastUsed

func (el ExtentListLRU) UpdateLastUsed(lur Extent, step time.Duration) ExtentListLRU

UpdateLastUsed updates the ExtentListLRU's LastUsed field for the provided extent. The step is required in order to properly split extents.

type TimeRangeQuery

type TimeRangeQuery struct {
	// Statement is the timeseries database query (with tokenized timeranges where present) requested by the user
	Statement string
	// Extent provides the start and end times for the request from a timeseries database
	Extent Extent
	// Step indicates the amount of time in seconds between each datapoint in a TimeRangeQuery's resulting timeseries
	Step time.Duration
	// IsOffset is true if the query uses a relative offset modifier
	IsOffset bool
	// TimestampFieldName indicates the database field name for the timestamp field
	TimestampFieldName string
	// FastForwardDisable indicates whether the Time Range Query result should include fast forward data
	FastForwardDisable bool
	// TemplateURL is used by some Origin Types for templatization of url parameters containing timestamps
	TemplateURL *url.URL
}

TimeRangeQuery represents a timeseries database query parsed from an inbound HTTP request

func (*TimeRangeQuery) CalculateDeltas

func (trq *TimeRangeQuery) CalculateDeltas(have ExtentList) ExtentList

CalculateDeltas provides a list of extents that are not in a cached timeseries, when provided a list of extents that are cached.

func (*TimeRangeQuery) Clone

func (trq *TimeRangeQuery) Clone() *TimeRangeQuery

Clone returns an exact copy of a TimeRangeQuery

func (*TimeRangeQuery) NormalizeExtent

func (trq *TimeRangeQuery) NormalizeExtent()

NormalizeExtent adjusts the Start and End of a TimeRangeQuery's Extent to align against normalized boundaries.

func (*TimeRangeQuery) String

func (trq *TimeRangeQuery) String() string

type Timeseries

type Timeseries interface {
	// SetExtents sets the Extents of the Timeseries
	SetExtents(ExtentList)
	// Extents should return the list of time Extents having data present in the Timeseries
	Extents() ExtentList
	// TimeStampCount should return the number of unique timestamps across the timeseries
	TimestampCount() int
	// Step should return the Step Interval of the Timeseries
	Step() time.Duration
	// SetStep should update the Step Interval of the Timeseries
	SetStep(time.Duration)
	// Merge should merge the Timeseries collection into the source Timeseries
	Merge(bool, ...Timeseries)
	// Sort should uniqueify and sort all series by Timestamp
	Sort()
	// Clone should returns an exact duplicate source the Timeseries
	Clone() Timeseries
	// CropToRange should reduce time range of the Timeseries to the provided Extent
	CropToRange(Extent)
	// CropToSize should reduce time range of the Timeseries to the provided element size using
	// a least-recently-used methodology, while limiting the upper extent to the provided time,
	// in order to support backfill tolerance
	CropToSize(int, time.Time, Extent)
	// SeriesCount returns the number of individual Series in the Timeseries object
	SeriesCount() int
	// ValueCount returns the count of all values across all Series in the Timeseries object
	ValueCount() int
	// Size returns the approximate memory byte size of the timeseries object
	Size() int
}

Timeseries represents a Response Object from a Timeseries Database

Jump to

Keyboard shortcuts

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