v0.0.0-...-fc27e31 Latest Latest

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

Go to latest
Published: Nov 2, 2016 License: MIT Imports: 12 Imported by: 0




This section is empty.


View Source
var (
	ErrAPI      = errors.New("api error")
	ErrNoData   = errors.New("no data")
	ErrNotFound = errors.New("not found")
	ErrBadQuery = errors.New("bad query")


This section is empty.


type Client

type Client interface {
	Datasets() ([]*Dataset, error)
	Write(*Dataset) error
	Delete(string) error
	Query(*Query) (*Dataset, error)

type Dataset

type Dataset struct {
	Name    string     // Name of this dataset
	Columns []string   // Ordered array of cols
	Mtx     *mtx.Dense `json:"-"` // Dense Matrix contains all values in the dataset
	Stats   *Stats

	WithValues bool
	// contains filtered or unexported fields

Dataset consists of a name and an ordered array of column names

func (Dataset) CPos

func (ds Dataset) CPos(name string) int

CPos returns the position of a column name in a dataset. If the column does not exist it returns -1

func (Dataset) Len

func (ds Dataset) Len() int

Len returns the length (number of rows) of the dataset

func (*Dataset) MarshalJSON

func (ds *Dataset) MarshalJSON() ([]byte, error)

func (*Dataset) Next

func (ds *Dataset) Next() ([]float64, error)

Next returns the next row of values If all values have been traversed it returns io.EOF. Implements the loader.Reader interface

func (*Dataset) UnmarshalJSON

func (ds *Dataset) UnmarshalJSON(data []byte) error

type Function

type Function struct {
	Name string

func (Function) Apply

func (fn Function) Apply(mx []mtx.Matrix) *mtx.Dense

type Grouping

type Grouping struct {
	Name  string
	Index int
	Max   time.Duration

Grouping represents a "group by" configuration

func NewGrouping

func NewGrouping(arg string) *Grouping

NewGrouping returns a grouping based on a string parameter. See documentation for Duration str format

Duration,0,1min ^--------^-^----Name,Index,DurationStr

func (Grouping) Group

func (grp Grouping) Group(other *mtx.Dense) []mtx.Matrix

func (Grouping) MarshalJSON

func (grp Grouping) MarshalJSON() ([]byte, error)

func (Grouping) String

func (grp Grouping) String() string

func (Grouping) UnmarshalJSON

func (grp Grouping) UnmarshalJSON(data []byte) error

type Query

type Query struct {
	Datasets []struct {
		Name    string   // Name of the dataset
		Columns []string // Columns within the dataset to query
	Function *Function
	Grouping *Grouping

Query can be used to combine the results of multiple datasets into a single matrix of values. Queries can originate from the command line as arguments, a URL query string, or a JSON encoded payload.

Command line arguments take the same form as URL encoding

Text Specification: d=DS1,x,y&d=DS2,z,fuu&grouping=Duration,0,1m&fn=avg

func NewQuery

func NewQuery(args []string, function, grouping string) *Query

NewQuery constructs a Query from the provided args and optionally specified function. If function is specified the query returns aggregated

func NewQueryQS

func NewQueryQS(u *url.URL) *Query

NewQueryQS constructs a query from a url.URL

func (Query) Apply

func (query Query) Apply(mx *mtx.Dense) *mtx.Dense

Apply returns a new modified matrix based on the query

func (Query) Columns

func (query Query) Columns() []string

Columns returns a flattened ordered array of Column names

func (Query) Len

func (query Query) Len() int

Len returns the length of the Query

func (Query) String

func (query Query) String() string

String returns a valid URL query string

type Stats

type Stats struct {
	Rows    int
	Columns int

Stats contain statistics about the underlying data in a dataset

Jump to

Keyboard shortcuts

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