Documentation ¶
Index ¶
- Variables
- func Bool(v interface{}) (bool, bool)
- func Equal(o1, o2 interface{}) bool
- func Float(v interface{}) (float64, bool)
- func FloatNoBool(v interface{}) (float64, bool)
- func Int(v interface{}) (int64, bool)
- func IntNoBool(v interface{}) (int64, bool)
- func String(v interface{}) (string, bool)
- func ToString(v interface{}) string
- func Unregister(name string)
- type Aggregator
- type AggregatorFunc
- type ArgBasic
- type ArgBasicFunc
- type ArgType
- type Basic
- type BasicFunc
- type BasicInit
- type Buffer
- type BufferIterator
- type ChanResult
- type ChannelPipe
- type ConstIterator
- type Datapoint
- func (dp *Datapoint) Bool() (bool, error)
- func (dp *Datapoint) Float() (float64, error)
- func (dp *Datapoint) Int() (int64, error)
- func (dp *Datapoint) MapElement(k string) (interface{}, error)
- func (dp *Datapoint) String() (string, error)
- func (dp *Datapoint) Time() time.Time
- func (dp *Datapoint) ToString() string
- type DatapointArrayIterator
- type EmptyIterator
- type Iterator
- type IteratorFromBI
- type Pipe
- func (p *Pipe) Append(e *PipeElement)
- func (p *Pipe) Copy() *Pipe
- func (p *Pipe) GetConst() (interface{}, error)
- func (p Pipe) Input(b *Buffer)
- func (p *Pipe) InputIterator(n Iterator)
- func (p *Pipe) IsBasic() bool
- func (p *Pipe) Join(p2 *Pipe)
- func (p *Pipe) Last(dp *Datapoint) (*Datapoint, error)
- func (p *Pipe) MarshalJSON() ([]byte, error)
- func (p *Pipe) Next(dp *Datapoint) (*Datapoint, error)
- func (p *Pipe) OneToOne() bool
- func (p *Pipe) Simplify() *Pipe
- func (p *Pipe) String() string
- func (p *Pipe) UnmarshalJSON(b []byte) error
- type PipeElement
- type TestCase
- type Transform
- type TransformArg
- type TransformConstructor
- type TransformEnv
- type TransformIterator
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // TransformRegistry is the map of all the transforms that are currently registered. // Do not manually add/remove elements from this map. // Use Transform.Register to insert new transforms. TransformRegistry = map[string]*Transform{} // RegistryLock enables adding/deleting transforms during runtime. It is exported, since some // applications (heedy) might want to print out the registry RegistryLock = &sync.RWMutex{} )
View Source
var AddTransform = &Transform{ Name: "add", Description: "add", Args: []TransformArg{ TransformArg{ Description: "Value to add to the datapoint", Type: TransformArgType, }, TransformArg{ Description: "Value to add to the datapoint", Type: TransformArgType, }, }, Constructor: NewArgBasic(func(args []*Datapoint, consts []interface{}, pipes []*Pipe, out *Datapoint) (*Datapoint, error) { f1, err := args[0].Float() if err == nil { var f2 float64 f2, err = args[1].Float() out.Data = f1 + f2 } return out, err }), }
View Source
var AndTransform = &Transform{ Name: "and", Description: "logical and", Args: []TransformArg{ TransformArg{ Description: "Value to and against data", Type: TransformArgType, }, TransformArg{ Description: "Value to and against data", Type: TransformArgType, }, }, Constructor: NewArgBasic(func(args []*Datapoint, consts []interface{}, pipes []*Pipe, out *Datapoint) (*Datapoint, error) { f1, err := args[0].Bool() if err == nil { var f2 bool f2, err = args[1].Bool() out.Data = f1 && f2 } return out, err }), }
View Source
var DivTransform = &Transform{ Name: "sub", Description: "divides datapoint by arg", Args: []TransformArg{ TransformArg{ Description: "denominator", Type: TransformArgType, }, TransformArg{ Description: "Value to add to the datapoint", Type: TransformArgType, }, }, Constructor: NewArgBasic(func(args []*Datapoint, consts []interface{}, pipes []*Pipe, out *Datapoint) (*Datapoint, error) { f1, err := args[0].Float() if err == nil { var f2 float64 f2, err = args[1].Float() out.Data = f1 / f2 } return out, err }), }
View Source
var Dt = &Transform{ Name: "dt", Description: "Gives access to the datapoint's duration", Documentation: string(resources.MustAsset("docs/transforms/dt.md")), Constructor: func(transform *Transform, consts []interface{}, pipes []*Pipe) (TransformIterator, error) { return dtIter{}, nil }, }
View Source
var EqTransform = &Transform{ Name: "eq", Description: "returns true if the data of the incoming stream is not equal to the value of the first arg", Args: []TransformArg{ TransformArg{ Description: "Value to check against data", Type: TransformArgType, }, TransformArg{ Description: "Value to check against data", Type: TransformArgType, }, }, Constructor: NewArgBasic(func(args []*Datapoint, consts []interface{}, pipes []*Pipe, out *Datapoint) (*Datapoint, error) { out.Data = Equal(args[0].Data, args[1].Data) return out, nil }), }
View Source
var ErrBeforeStart = errors.New("There is no value for this query yet")
View Source
var GtTransform = &Transform{ Name: "gt", Description: "returns true if the data of the incoming stream is greater than the value of the first arg", Args: []TransformArg{ TransformArg{ Description: "Value to check against data", Type: TransformArgType, }, TransformArg{ Description: "Value to check against data", Type: TransformArgType, }, }, Constructor: NewArgBasic(func(args []*Datapoint, consts []interface{}, pipes []*Pipe, out *Datapoint) (*Datapoint, error) { f1, err := args[0].Float() if err == nil { var f2 float64 f2, err = args[1].Float() out.Data = f1 > f2 } return out, err }), }
View Source
var GteTransform = &Transform{ Name: "gte", Description: "returns true if the data of the incoming stream is greater than or equal to the value of the first arg", Args: []TransformArg{ TransformArg{ Description: "Value to check against data", Type: TransformArgType, }, TransformArg{ Description: "Value to check against data", Type: TransformArgType, }, }, Constructor: NewArgBasic(func(args []*Datapoint, consts []interface{}, pipes []*Pipe, out *Datapoint) (*Datapoint, error) { f1, err := args[0].Float() if err == nil { var f2 float64 f2, err = args[1].Float() out.Data = f1 >= f2 } return out, err }), }
View Source
var Identity = &Transform{ Name: "d", Description: `Represents the data portion of the current datapoint. It is the identity transform.`, Documentation: string(resources.MustAsset("docs/transforms/d.md")), Args: []TransformArg{ TransformArg{ Description: "If it is given an integer, peeks to the relative index in array. If string, tries to get the object key", Type: ConstArgType, Optional: true, Default: MustPipe(NewConstTransform(0), nil), Schema: map[string]interface{}{ "oneOf": []interface{}{ map[string]interface{}{ "type": "string", }, map[string]interface{}{ "type": "integer", }, }, }, }, }, Constructor: func(transform *Transform, consts []interface{}, pipes []*Pipe) (TransformIterator, error) { idx, ok := Int(consts[0]) if ok { return peekIterator{int(idx)}, nil } _, ok = consts[0].(string) if !ok { return nil, errors.New("Argument of invalid type") } return &Basic{ ConstArgs: consts, PipeArgs: pipes, Args: nil, f: basicGetElement, }, nil }, }
View Source
var IdentityPipe = MustPipe(Identity, []*Pipe{MustPipe(NewConstTransform(0), nil)})
View Source
var LtTransform = &Transform{ Name: "lt", Description: "returns true if the data of the incoming stream is less than the value of the first arg", Args: []TransformArg{ TransformArg{ Description: "Value to check against data", Type: TransformArgType, }, TransformArg{ Description: "Value to check against data", Type: TransformArgType, }, }, Constructor: NewArgBasic(func(args []*Datapoint, consts []interface{}, pipes []*Pipe, out *Datapoint) (*Datapoint, error) { f1, err := args[0].Float() if err == nil { var f2 float64 f2, err = args[1].Float() out.Data = f1 < f2 } return out, err }), }
View Source
var LteTransform = &Transform{ Name: "lte", Description: "returns true if the data of the incoming stream is less than or equal to the value of the first arg", Args: []TransformArg{ TransformArg{ Description: "Value to check against data", Type: TransformArgType, }, TransformArg{ Description: "Value to check against data", Type: TransformArgType, }, }, Constructor: NewArgBasic(func(args []*Datapoint, consts []interface{}, pipes []*Pipe, out *Datapoint) (*Datapoint, error) { f1, err := args[0].Float() if err == nil { var f2 float64 f2, err = args[1].Float() out.Data = f1 <= f2 } return out, err }), }
View Source
var ModTransform = &Transform{ Name: "mod", Description: "modulo", Args: []TransformArg{ TransformArg{ Description: "mod by this", Type: TransformArgType, }, TransformArg{ Description: "Value to add to the datapoint", Type: TransformArgType, }, }, Constructor: NewArgBasic(func(args []*Datapoint, consts []interface{}, pipes []*Pipe, out *Datapoint) (*Datapoint, error) { f1, err := args[0].Int() if err == nil { var f2 int64 f2, err = args[1].Int() out.Data = f1 % f2 } return out, err }), }
View Source
var MulTransform = &Transform{ Name: "sub", Description: "multiplies datapoint by arg", Args: []TransformArg{ TransformArg{ Description: "Value to multiply", Type: TransformArgType, }, TransformArg{ Description: "Value to add to the datapoint", Type: TransformArgType, }, }, Constructor: NewArgBasic(func(args []*Datapoint, consts []interface{}, pipes []*Pipe, out *Datapoint) (*Datapoint, error) { f1, err := args[0].Float() if err == nil { var f2 float64 f2, err = args[1].Float() out.Data = f1 * f2 } return out, err }), }
View Source
var NeTransform = &Transform{ Name: "ne", Description: "returns true if the data of the incoming stream is not equal to the value of the first arg", Args: []TransformArg{ TransformArg{ Description: "Value to check against data", Type: TransformArgType, }, TransformArg{ Description: "Value to check against data", Type: TransformArgType, }, }, Constructor: NewArgBasic(func(args []*Datapoint, consts []interface{}, pipes []*Pipe, out *Datapoint) (*Datapoint, error) { out.Data = !Equal(args[0].Data, args[1].Data) return out, nil }), }
View Source
var NegTransform = &Transform{ Name: "neg", Description: "Negation of numbers", Constructor: NewBasic(nil, func(dp *Datapoint, args []*Datapoint, consts []interface{}, pipes []*Pipe, out *Datapoint) (*Datapoint, error) { b, ok := dp.Data.(bool) if ok { out.Data = !b return out, nil } f, err := dp.Float() out.Data = -f return out, err }), }
View Source
var NotTransform = &Transform{ Name: "not", Description: "Boolean not", Constructor: NewBasic(nil, func(dp *Datapoint, args []*Datapoint, consts []interface{}, pipes []*Pipe, out *Datapoint) (*Datapoint, error) { b, err := dp.Bool() out.Data = !b return out, err }), }
View Source
var OrTransform = &Transform{ Name: "or", Description: "logical or", Args: []TransformArg{ TransformArg{ Description: "Value to or against data", Type: TransformArgType, }, TransformArg{ Description: "Value to and against data", Type: TransformArgType, }, }, Constructor: NewArgBasic(func(args []*Datapoint, consts []interface{}, pipes []*Pipe, out *Datapoint) (*Datapoint, error) { f1, err := args[0].Bool() if err == nil { var f2 bool f2, err = args[1].Bool() out.Data = f1 || f2 } return out, err }), }
View Source
var PowTransform = &Transform{ Name: "pow", Description: "sets datapoint to arg's power", Args: []TransformArg{ TransformArg{ Description: "Value to multiply", Type: TransformArgType, }, TransformArg{ Description: "Value to add to the datapoint", Type: TransformArgType, }, }, Constructor: NewArgBasic(func(args []*Datapoint, consts []interface{}, pipes []*Pipe, out *Datapoint) (*Datapoint, error) { f1, err := args[0].Float() if err == nil { var f2 float64 f2, err = args[1].Float() out.Data = math.Pow(f1, f2) } return out, err }), }
View Source
var SubTransform = &Transform{ Name: "sub", Description: "subtracts first argument from the datapoint", Args: []TransformArg{ TransformArg{ Description: "Value to subtract from the datapoint", Type: TransformArgType, }, TransformArg{ Description: "Value to add to the datapoint", Type: TransformArgType, }, }, Constructor: NewArgBasic(func(args []*Datapoint, consts []interface{}, pipes []*Pipe, out *Datapoint) (*Datapoint, error) { f1, err := args[0].Float() if err == nil { var f2 float64 f2, err = args[1].Float() out.Data = f1 - f2 } return out, err }), }
View Source
var T = &Transform{ Name: "t", Description: "Gives access to the datapoint's timestamp", Documentation: string(resources.MustAsset("docs/transforms/t.md")), Constructor: func(transform *Transform, consts []interface{}, pipes []*Pipe) (TransformIterator, error) { return tIter{}, nil }, }
Functions ¶
func Float ¶
Float takes an interface that was marshalled with the json package and returns it as a float, or gives an error
func FloatNoBool ¶
func Int ¶
Int takes an interface that was unmarshalled with the json package, and returns it as an int, or returns false
func Unregister ¶
func Unregister(name string)
Unregister removes the given named transform from the registry
Types ¶
type Aggregator ¶
type Aggregator struct { ConstArgs []interface{} PipeArgs []*Pipe // contains filtered or unexported fields }
func (*Aggregator) Next ¶
func (a *Aggregator) Next(e *TransformEnv, out *Datapoint) (*Datapoint, error)
func (*Aggregator) OneToOne ¶
func (a *Aggregator) OneToOne() bool
type AggregatorFunc ¶
type AggregatorFunc func(e *TransformEnv, consts []interface{}, pipes []*Pipe, out *Datapoint) (*Datapoint, error)
type ArgBasic ¶
type ArgBasic struct { ConstArgs []interface{} PipeArgs []*Pipe Args []*Datapoint // contains filtered or unexported fields }
type ArgBasicFunc ¶
type ArgType ¶
type ArgType int
ArgType gives the types of args that a trasnform can accept
func (ArgType) MarshalJSON ¶
func (*ArgType) UnmarshalJSON ¶
type Basic ¶
type Basic struct { ConstArgs []interface{} PipeArgs []*Pipe Args []*Datapoint // contains filtered or unexported fields }
type Buffer ¶
type Buffer struct { Input Iterator Pages *list.List // The last page, after which there are no more datapoints // Initially set to max int64 EndPage uint64 // An error that was encountered Error error Iterators []*BufferIterator }
func (*Buffer) Iterator ¶
func (b *Buffer) Iterator() *BufferIterator
type BufferIterator ¶
func (*BufferIterator) Close ¶
func (i *BufferIterator) Close()
func (*BufferIterator) Next ¶
func (i *BufferIterator) Next() (*Datapoint, error)
type ChanResult ¶
type ChannelPipe ¶
type ChannelPipe struct { Sender chan *Datapoint Receiver chan ChanResult }
func NewChannelPipe ¶
func NewChannelPipe(p *Pipe) *ChannelPipe
func (*ChannelPipe) Close ¶
func (cp *ChannelPipe) Close()
type ConstIterator ¶
type ConstIterator struct {
Value interface{}
}
func (*ConstIterator) Next ¶
func (c *ConstIterator) Next(e *TransformEnv, out *Datapoint) (*Datapoint, error)
func (*ConstIterator) OneToOne ¶
func (c *ConstIterator) OneToOne() bool
type Datapoint ¶
type Datapoint struct { Timestamp float64 `json:"t"` Duration float64 `json:"dt"` Data interface{} `json:"d"` }
func (*Datapoint) MapElement ¶
type DatapointArrayIterator ¶
type DatapointArrayIterator struct { Datapoints []Datapoint // contains filtered or unexported fields }
func NewDatapointArrayIterator ¶
func NewDatapointArrayIterator(dpa []Datapoint) *DatapointArrayIterator
type EmptyIterator ¶
type EmptyIterator struct{}
type IteratorFromBI ¶
type IteratorFromBI struct {
BI *BufferIterator
}
type Pipe ¶
type Pipe struct {
Arr []*PipeElement
}
func (*Pipe) Append ¶
func (p *Pipe) Append(e *PipeElement)
Append returns a pipe with the given PipeElement added
func (*Pipe) InputIterator ¶
InputNexter uses an iterator interface as input
func (*Pipe) MarshalJSON ¶
func (*Pipe) UnmarshalJSON ¶
type PipeElement ¶
type PipeElement struct { Env *TransformEnv Args []*Pipe Iter TransformIterator // These three are here to allow copying a pipe by re-generating it from scratch ConstArgs []interface{} PipeArgs []*Pipe Transform *Transform }
func NewPipeElement ¶
func NewPipeElement(t *Transform, args []*Pipe) (*PipeElement, error)
func (*PipeElement) Copy ¶
func (pe *PipeElement) Copy() *PipeElement
func (*PipeElement) GetConst ¶
func (pe *PipeElement) GetConst(in interface{}) (interface{}, error)
func (*PipeElement) Input ¶
func (pe *PipeElement) Input(b *Buffer)
func (*PipeElement) IsBasic ¶
func (pe *PipeElement) IsBasic() bool
func (*PipeElement) String ¶
func (pe *PipeElement) String() string
type TestCase ¶
type TestCase struct { Pipescript string // The script to run Input []Datapoint // The input datapoints Parsed string // The output of the parsed pipe.String(). "" if there is to be an error OutputError bool // Whether there is to be an error during output Output []Datapoint // The output Datapoints }
type Transform ¶
type Transform struct { Name string `json:"name"` // The name of the transform Description string `json:"description"` // A single line description of the transform Documentation string `json:"documentation"` // Full markdown documentation of the transform InputSchema map[string]interface{} `json:"ischema"` // The schema of the input datapoint that the given transform expects (optional) OutputSchema map[string]interface{} `json:"oschema"` // The schema of the output data that this transform gives (optional). Args []TransformArg `json:"args"` // The arguments that the transform accepts Constructor TransformConstructor `json:"-"` // The function that constructs a transform }
func NewConstTransform ¶
func NewConstTransform(v interface{}) *Transform
func NewObjectTransform ¶
type TransformArg ¶
type TransformArg struct { Description string `json:"description"` // A description of what the arg represents Schema map[string]interface{} `json:"schema"` // The schema that the arg conforms to Optional bool `json:"optional"` // Whether the arg is optional Default *Pipe `json:"default,omitempty"` // If the arg is optional, what is its default value Type ArgType `json:"arg_type"` // The type expected of the arg }
type TransformConstructor ¶
type TransformConstructor func(transform *Transform, consts []interface{}, pipes []*Pipe) (TransformIterator, error)
func NewAggregator ¶
func NewAggregator(f AggregatorFunc) TransformConstructor
func NewArgBasic ¶
func NewArgBasic(f ArgBasicFunc) TransformConstructor
func NewBasic ¶
func NewBasic(i BasicInit, f BasicFunc) TransformConstructor
type TransformEnv ¶
type TransformEnv struct { Iter *BufferIterator ArgIters []*BufferIterator }
type TransformIterator ¶
type TransformIterator interface { Next(*TransformEnv, *Datapoint) (*Datapoint, error) OneToOne() bool }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
* Copyright (c) 2015 The heedy Contributors (see AUTHORS) Licensed under the MIT license.
|
* Copyright (c) 2015 The heedy Contributors (see AUTHORS) Licensed under the MIT license. |
Package transforms imports all of the transforms that are available with PipeScript.
|
Package transforms imports all of the transforms that are available with PipeScript. |
core
Package core contains the core basic transforms which are available in PipeScript.
|
Package core contains the core basic transforms which are available in PipeScript. |
datetime
Package datetime offers transforms useful for processing timestamps
|
Package datetime offers transforms useful for processing timestamps |
numeric
Package numeric contains basic statistical transforms (such as mean)
|
Package numeric contains basic statistical transforms (such as mean) |
strings
Package strings implements basic text processing transforms
|
Package strings implements basic text processing transforms |
Click to show internal directories.
Click to hide internal directories.