transforms

package
v0.0.0-...-abd831d Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2018 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDatabaseDateFormat = "YYYY-MM-DDTHH:MM:SSZ"
)
View Source
const (
	NoGroupBy = ""
)

Variables

View Source
var ErrTimeseriesNoEarlierData = errors.New("could not trim timeseries because its start time is later than the requested start time")

ErrTimeseriesNoEarlierData is returned when trimming or resampling a timeseries when the desired start time is later than the earliest point in the timeseries.

Functions

func NewAggregate

func NewAggregate(aqlBody string) (*aggregate, error)

func NewApply

func NewApply(aqlBody string) (*apply, error)

func NewLookup

func NewLookup(aqlBody string) (*lookup, error)

func Parse

Parse parses and initializes a transform given its body and input sequence.

Types

type Aggregate

type Aggregate struct {
	Select  []AggregateTerm `"AGGREGATE " @@ { "," @@ }`
	GroupBy []string        `["GROUP " "BY " @Ident { "," @Ident}]`
}

type AggregateTerm

type AggregateTerm struct {
	Column string `(@Ident`

	Function *FunctionApplication `| @@)`
	Alias    string               `["AS " @Ident]`
}

type Apply

type Apply struct {
	Projections []ConversionColumn `"APPLY " @@ {"," @@}`
}

type ArgumentMap

type ArgumentMap func(args []interface{}) []interface{}

ArgumentMap is used to map the incoming engine.Message into a slice of interface that is correct for a Reducer.Reduce() method.

var (
	Reducers                  = map[string]Reducer{"cdf(": &cdf{}, "quantile(": &quantile{}, "count(": &count{}, "sum(": &sum{}, "min(": &min{}, "max(": &max{}, "avg(": &avg{}, "zoh(": &zoh{}}
	DefaultArgMap ArgumentMap = func(i []interface{}) []interface{} { return i }
)

The reason that Function's have to include the opening ( is because we can't parse these as Ident due the issue in https://github.com/alecthomas/participle/issues/3

type CastColumn

type CastColumn struct {
	Column   string  `"CAST(" @Ident`
	DestType string  `"AS " @Ident ")"`
	Alias    *string `["AS " @Ident]`
}

type CastFn

type CastFn func(src interface{}) (interface{}, error)

CastFn casts a source interface into a destination interface. A nil interface maps to a nil interface regardless of the destination type.

type Column

type Column struct {
	Column string  `@Ident`
	Alias  *string `["AS " @Ident]`
}

type ConversionColumn

type ConversionColumn struct {
	Lookup *Column     `@@`
	Cast   *CastColumn `| @@`
}

type FunctionApplication

type FunctionApplication struct {
	Function string             `@Function`
	Columns  []FunctionArgument `@@ { "," @@ } ")"`
}

type FunctionArgument

type FunctionArgument struct {
	Column string   `@Ident`
	String *string  `| @String`
	Number *float64 `| @Number`
}

type JoinCondition

type JoinCondition struct {
	T1Column *LookupColumn `@@`
	T2Column *LookupColumn `"=" @@`
}

type Lookup

type Lookup struct {
	Projection   []LookupColumn  `"LOOKUP " @@ {"," @@}`
	FromSource   string          `"FROM " @Ident`
	InnerJoin    bool            `(@"INNER "`
	OuterJoin    bool            `| @"OUTER ")`
	LookupSource string          `"JOIN " @Ident`
	Conditions   []JoinCondition `"ON " @@ { "AND " @@}`
}

type LookupColumn

type LookupColumn struct {
	Source string  `@Ident "."`
	Column string  `@Ident`
	Alias  *string `["AS " @Ident]`
}

type Reducer

type Reducer interface {
	ParameterLen() int //ParameterLen returns the number of parameters the function takes (should be constant)
	SetArgumentMap(ArgumentMap)
	Reduce(arg []interface{}) error
	Copy() Reducer //Returns a reducer with blank state
	Return() *float64
}

type Timeseries

type Timeseries []TimeseriesItem

Timeseries represents a data point changing in time. It is assumed to be ordered by Time, ascending.

func (Timeseries) Equals

func (t Timeseries) Equals(w interface{}) bool

Equals check for equality with "something". This is to make Timeseries satisfy the Value interface.

func (Timeseries) Len

func (t Timeseries) Len() int

func (Timeseries) Less

func (t Timeseries) Less(i, j int) bool

func (Timeseries) Mean

func (t Timeseries) Mean(start time.Time, end time.Time) *float64

Mean computes the ZOH average of the timeseries between `start` and `end`. It returns NaN if start is before the earliest point of the timeseries or if `end` is not after `start`.

func (Timeseries) Start

func (t Timeseries) Start() *time.Time

Start returns the first time where the series is defined.

func (Timeseries) Swap

func (t Timeseries) Swap(i, j int)

type TimeseriesItem

type TimeseriesItem struct {
	Time  time.Time
	Value float64
}

TimeseriesItem is a point in a timeseries

func (TimeseriesItem) Equals

func (ti TimeseriesItem) Equals(w interface{}) bool

Equals checks for equality with "something". This is to make TimeseriesItem satisfy the Value interface.

Source Files

  • aggregate.go
  • apply.go
  • avg.go
  • cast.go
  • cdf.go
  • common.go
  • count.go
  • lookup.go
  • max.go
  • min.go
  • quantile.go
  • sum.go
  • transforms.go
  • zoh.go

Jump to

Keyboard shortcuts

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