Documentation ¶
Overview ¶
Lexer and parser for expressions of the form:
f(g(h("foo"), i(3, "bar")))
Note that while it does understand strings and numbers, it doesn't do binary operators. We can do those via functions if needed, ala add(x, y), sub(x, y), etc.
Caveats: * Only handles ASCII.
For context on how this was written please watch:
https://www.youtube.com/watch?v=HxaD_trXwRE
Index ¶
- Constants
- func AveFuncImpl(rows types.TraceSet) types.Trace
- func CountFuncImpl(rows types.TraceSet) types.Trace
- func GeoFuncImpl(rows types.TraceSet) types.Trace
- func MaxFuncImpl(rows types.TraceSet) types.Trace
- func MinFuncImpl(rows types.TraceSet) types.Trace
- func StdDevFuncImpl(rows types.TraceSet) types.Trace
- func SumFuncImpl(rows types.TraceSet) types.Trace
- type AveFunc
- type Context
- type CountFunc
- type FillFunc
- type FilterFunc
- type Func
- type GeoFunc
- type IQRRFunc
- type LogFunc
- type Node
- type NodeType
- type NormFunc
- type RatioFunc
- type RowsFromQuery
- type RowsFromShortcut
- type ScaleByAveFunc
- type ShortcutFunc
- type SumFunc
- type TraceAveFunc
- type TraceCovFunc
- type TraceStdDevFunc
- type TraceStepFunc
Constants ¶
const ( // MIN_STDDEV is the smallest standard deviation we will normalize, smaller // than this and we presume it's a standard deviation of zero. MIN_STDDEV = 0.001 )
Variables ¶
This section is empty.
Functions ¶
func AveFuncImpl ¶
AveFuncImpl averages the values of all argument traces into a single trace.
func GeoFuncImpl ¶
GeoFuncImpl take the geometric mean of the values of all argument rows into a single trace.
func MaxFuncImpl ¶
MaxFuncImpl puts the max of the values of all argument traces into a single trace.
func MinFuncImpl ¶
MinFuncImpl puts the min of the values of all argument traces into a single trace.
func StdDevFuncImpl ¶
StdDevFuncImpl puts the std deviation of the values of all argument traces into a single trace.
Types ¶
type AveFunc ¶
type AveFunc struct{}
func (AveFunc) Eval ¶
aveFunc implements Func and averages the values of all argument traces into a single trace.
vec32.MISSING_DATA_SENTINEL values are not included in the average. Note that if all the values at an index are vec32.MISSING_DATA_SENTINEL then the average will be vec32.MISSING_DATA_SENTINEL.
type Context ¶
type Context struct { RowsFromQuery RowsFromQuery RowsFromShortcut RowsFromShortcut Funcs map[string]Func // contains filtered or unexported fields }
Context stores all the info for a single parser.
A Context is not safe to call from multiple go routines.
func NewContext ¶
func NewContext(rowsFromQuery RowsFromQuery, rowsFromShortcut RowsFromShortcut) *Context
NewContext create a new parsing context that includes the basic functions.
type CountFunc ¶
type CountFunc struct{}
CountFunc implements Func and counts the number of non-sentinel values in all argument rows.
vec32.MISSING_DATA_SENTINEL values are not included in the count. Note that if all the values at an index are vec32.MISSING_DATA_SENTINEL then the count will be 0.
type FilterFunc ¶
type FilterFunc struct{}
func (FilterFunc) Describe ¶
func (FilterFunc) Describe() string
type Func ¶
Func defines a type for functions that can be used in the parser.
The traces returned will always have a Param of "id" that identifies the trace. See DESIGN.md for the Trace ID naming conventions.
type GeoFunc ¶
type GeoFunc struct{}
func (GeoFunc) Eval ¶
geoFunc implements Func and merges the values of all argument rows into a single trace with a geometric mean.
vec32.MISSING_DATA_SENTINEL and negative values are not included in the mean. Note that if all the values at an index are vec32.MISSING_DATA_SENTINEL or negative then the mean will be vec32.MISSING_DATA_SENTINEL.
type IQRRFunc ¶
type IQRRFunc struct{}
IQRRFunc implements Func and computes a new trace that is has all outliers set to MISSING_DATA_SENTINEL based on the interquartile range.
vec32.MISSING_DATA_SENTINEL values are not taken into account when computing the outliers.
type NormFunc ¶
type NormFunc struct{}
type ScaleByAveFunc ¶
type ScaleByAveFunc struct{}
func (ScaleByAveFunc) Describe ¶
func (ScaleByAveFunc) Describe() string
func (ScaleByAveFunc) Eval ¶
ScaleByAveFunc implements Func and Computes a new trace that is scaled by 1/(average of all values in the trace).
vec32.MISSING_DATA_SENTINEL values are not taken into account for the ave. If the entire vector is vec32.MISSING_DATA_SENTINEL then the result is also all vec32.MISSING_DATA_SENTINEL.
type ShortcutFunc ¶
type ShortcutFunc struct{}
func (ShortcutFunc) Describe ¶
func (ShortcutFunc) Describe() string
type SumFunc ¶
type SumFunc struct{}
type TraceAveFunc ¶
type TraceAveFunc struct{}
func (TraceAveFunc) Describe ¶
func (TraceAveFunc) Describe() string
func (TraceAveFunc) Eval ¶
traceAveFunc implements Func and Computes the mean for all the values in a trace and return a trace where every value is that mean.
vec32.MISSING_DATA_SENTINEL values are not taken into account for the ave. If the entire vector is vec32.MISSING_DATA_SENTINEL then the result is also all vec32.MISSING_DATA_SENTINEL.
type TraceCovFunc ¶
type TraceCovFunc struct{}
func (TraceCovFunc) Describe ¶
func (TraceCovFunc) Describe() string
func (TraceCovFunc) Eval ¶
traceCovFunc implements Func and Computes the Coefficient of Variation (std dev)/mean for all the values in a trace and return a trace where every value is the CoV.
vec32.MISSING_DATA_SENTINEL values are not taken into account for the ave. If the entire vector is vec32.MISSING_DATA_SENTINEL then the result is also all vec32.MISSING_DATA_SENTINEL.
type TraceStdDevFunc ¶
type TraceStdDevFunc struct{}
func (TraceStdDevFunc) Describe ¶
func (TraceStdDevFunc) Describe() string
func (TraceStdDevFunc) Eval ¶
traceStdDevFunc implements Func and Computes the std dev for all the values in a trace and return a trace where every value is that std dev.
vec32.MISSING_DATA_SENTINEL values are not taken into account for the ave. If the entire vector is vec32.MISSING_DATA_SENTINEL then the result is also all vec32.MISSING_DATA_SENTINEL.
type TraceStepFunc ¶
type TraceStepFunc struct{}
func (TraceStepFunc) Describe ¶
func (TraceStepFunc) Describe() string
func (TraceStepFunc) Eval ¶
TraceStepFunc implements Func and Computes the step function, i.e the ratio of the ave of the first half of the trace divided by the ave of the second half of the trace.
vec32.MISSING_DATA_SENTINEL values are not taken into account for the ave. If the entire vector is vec32.MISSING_DATA_SENTINEL then the result is also all vec32.MISSING_DATA_SENTINEL.