summary

package
v0.0.0-...-11fc026 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Count = recent(
	"summarize.count",
	func(slice []float64) float64 {
		count := 0
		for i := range slice {
			if math.IsNaN(slice[i]) {
				continue
			}
			count++
		}
		return float64(count)
	},
)

Count computes the number of non-missing points in the line

View Source
var Current = function.MakeFunction(
	"summarize.current",
	func(list api.SeriesList) function.ScalarSet {
		result := function.ScalarSet{}
		for i := range list.Series {
			values := list.Series[i].Values
			result = append(result, function.TaggedScalar{
				TagSet: list.Series[i].TagSet,
				Value:  values[len(values)-1],
			})
		}
		return result
	},
)

Current computes the last tagged scalar for each time series.

View Source
var FirstNotNaN = recent(
	"summarize.first_not_nan",
	func(slice []float64) float64 {
		for i := range slice {
			if !math.IsNaN(slice[i]) {
				return slice[i]
			}
		}
		return math.NaN()
	},
)

FirstNotNaN computes the first not NaN tagged scalar for each time series.

View Source
var Integral = recentScaled(
	"summarize.integral",
	func(slice []float64, timerange api.Timerange) float64 {
		sum := 0.0
		for i := range slice {
			if math.IsNaN(slice[i]) {
				continue
			}
			sum += slice[i]
		}
		return sum * timerange.Resolution().Seconds()
	},
)

Integral computes the (scaled) integral of the time series line.

View Source
var LastNotNaN = recent(
	"summarize.last_not_nan",
	func(slice []float64) float64 {
		for i := range slice {
			if !math.IsNaN(slice[len(slice)-1-i]) {
				return slice[len(slice)-1-i]
			}
		}
		return math.NaN()
	},
)

LastNotNaN computes the last not NaN tagged scalar for each time series.

View Source
var Max = recent(
	"summarize.max",
	func(slice []float64) float64 {
		max := math.NaN()
		for i := range slice {
			if math.IsNaN(max) {
				max = slice[i]
			}
			if math.IsNaN(slice[i]) {
				continue
			}
			max = math.Max(max, slice[i])
		}
		return max
	},
)

Max computes a maximum tagged scalar for each time series line.

View Source
var Mean = recent(
	"summarize.mean",
	func(slice []float64) float64 {
		sum := 0.0
		count := 0
		for i := range slice {
			if math.IsNaN(slice[i]) {
				continue
			}
			sum += slice[i]
			count++
		}
		return sum / float64(count)
	},
)

Mean computes an average tagged scalar for each time series line.

View Source
var Min = recent(
	"summarize.min",
	func(slice []float64) float64 {
		min := math.NaN()
		for i := range slice {
			if math.IsNaN(min) {
				min = slice[i]
			}
			if math.IsNaN(slice[i]) {
				continue
			}
			min = math.Min(min, slice[i])
		}
		return min
	},
)

Min computes a minimum tagged scalar for each time series line.

View Source
var Oldest = function.MakeFunction(
	"summarize.oldest",
	func(list api.SeriesList) function.ScalarSet {
		result := function.ScalarSet{}
		for i := range list.Series {
			values := list.Series[i].Values
			result = append(result, function.TaggedScalar{
				TagSet: list.Series[i].TagSet,
				Value:  values[0],
			})
		}
		return result
	},
)

Oldest computes the first tagged scalar for each time series.

View Source
var Total = recent(
	"summarize.total",
	func(slice []float64) float64 {
		return float64(len(slice))
	},
)

Total computes the total number of points in the line

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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