collation

package
Version: v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RowPseudoField = "*" // a field name that represents a row level measure
)

Variables

View Source
var (
	ErrMeasureNotFound = errors.New("measure not found for field")
)

Functions

This section is empty.

Types

type Cardinality

type Cardinality struct {
	Precision int // precision between 4 and 18, inclusive
}

Cardinality is an approximate unique count of discrete observations over all time.

func (Cardinality) ContReader

func (c Cardinality) ContReader() ContReaderFunc

func (Cardinality) DiscWriter

func (c Cardinality) DiscWriter() DiscWriterFunc

func (Cardinality) Name

func (Cardinality) Name() string

func (Cardinality) Size

func (c Cardinality) Size() int

type Collator

type Collator struct {
	// contains filtered or unexported fields
}

func (Collator) Keys

func (c Collator) Keys() [][]byte

func (Collator) Name

func (c Collator) Name() string

func (Collator) Read

func (c Collator) Read(fml []FM, buf []byte) (Result, error)

Note that the byte slices in fml and buf must not be retained or reused by the collator.

func (Collator) Size

func (c Collator) Size() int

func (Collator) Update

func (c Collator) Update(r Row, buf []byte, init bool) error

Update reads the row and updates buf according to the schema's measures. buf contains the existing state of the collation record and is updated in- place. buf must be long enough for the schema's data. If init is true then the buffer contains unitialised data and the measures should initialise their state. If an error is returned then the buffer may be in an inconsistent state and should not be used further.

type ContReaderFunc

type ContReaderFunc func(buf []byte) (float64, error)

type ContWriterFunc

type ContWriterFunc func(buf []byte, init bool, v float64) error

type ContinuousInput

type ContinuousInput interface {
	ContWriter() ContWriterFunc
}

type ContinuousOutput

type ContinuousOutput interface {
	ContReader() ContReaderFunc
}

type Count

type Count struct{}

Count is a precise count of observations over all time.

func (Count) ContReader

func (Count) ContReader() ContReaderFunc

func (Count) Name

func (Count) Name() string

func (Count) RowWriter

func (Count) RowWriter() RowWriterFunc

func (Count) Size

func (Count) Size() int

type DiscReaderFunc

type DiscReaderFunc func(buf []byte) ([]byte, error)

type DiscWriterFunc

type DiscWriterFunc func(buf []byte, init bool, v []byte) error

type DiscreteInput

type DiscreteInput interface {
	DiscWriter() DiscWriterFunc
}

type DiscreteOutput

type DiscreteOutput interface {
	DiscReader() DiscReaderFunc
}

type FM

type FM struct {
	F []byte   // field name
	M [][]byte // list of measure names
}

FM is a field name with a list of measures

type FMV

type FMV struct {
	F []byte // field name
	M []byte // measure name
	V interface{}
}

FMV is a field name with a measure name and a value

func (FMV) String

func (f FMV) String() string

type FV

type FV struct {
	F, V []byte // field name and value
}

FV is a field name with a value

type FVList

type FVList []FV

func (FVList) KeyValue

func (fv FVList) KeyValue(keys [][]byte) (uint64, bool)

KeyValue builds a key value by locating Query criteria fields corresponding to the key names supplied and hashing their names and values. It returns false as the second argument if the key could not be constructed, e.g. if one of the keys does not match a field in the query criteria. keys must be sorted in ascending order.

type FieldSpec

type FieldSpec struct {
	Pattern string
}

A FieldSpec specifies a field contained in an incoming observation.

type Filter

type Filter struct {
}

A Filter specifies criteria by which a record is selected.

type KeySpec

type KeySpec struct {
	Field FieldSpec
}

A KeySpec specifies a key field in a schema.

type Max

type Max struct{}

Max is a precise maximum of continuous observations over all time.

func (Max) ContReader

func (Max) ContReader() ContReaderFunc

func (Max) ContWriter

func (Max) ContWriter() ContWriterFunc

func (Max) Name

func (Max) Name() string

func (Max) Size

func (Max) Size() int

type Mean

type Mean struct{}

Mean is a precise mean of continuous observations over all time.

func (Mean) ContReader

func (Mean) ContReader() ContReaderFunc

func (Mean) ContWriter

func (Mean) ContWriter() ContWriterFunc

func (Mean) Name

func (Mean) Name() string

func (Mean) Size

func (Mean) Size() int

type Measure

type Measure interface {
	Size() int
	Name() string
}

type MeasureSpec

type MeasureSpec struct {
	Field    FieldSpec
	Measures []Measure
}

A MeasureSpec specifies a measure field in a schema.

type Min

type Min struct{}

Min is a precise minimum of continuous observations over all time.

func (Min) ContReader

func (Min) ContReader() ContReaderFunc

func (Min) ContWriter

func (Min) ContWriter() ContWriterFunc

func (Min) Name

func (Min) Name() string

func (Min) Size

func (Min) Size() int

type Query

type Query struct {
	FieldMeasures []FM   // fields and the measures to take from them
	Criteria      FVList // fields and values in the row. Field names must be unique.
}

Query is a row of data to be collated containing fields and their values.

func (*Query) KeyValue

func (q *Query) KeyValue(keys [][]byte) (uint64, bool)

KeyValue builds a key value by locating Query criteria fields corresponding to the key names supplied and hashing their names and values. It returns false as the second argument if the key could not be constructed, e.g. if one of the keys does not match a field in the query criteria. keys must be sorted in ascending order.

func (*Query) Reset

func (q *Query) Reset()

Reset clears the query of all data, preserving allocated memory.

type Record

type Record struct {
}

A Record is one instance of a schema for a particular combination of keys.

type Result

type Result struct {
	FieldMeasureValues []FMV // fields and the measure values
}

Result is a result of a query.

type Row

type Row struct {
	ReceiveTime time.Time // received time
	DataTime    time.Time // data time
	Data        FVList    // fields and values in the row. Field names must be unique.
}

Row is a row of data to be collated containing fields and their values.

func (*Row) KeyValue

func (r *Row) KeyValue(keys [][]byte) (uint64, bool)

KeyValue builds a key value by locating Row fields corresponding to the key names supplied and hashing their names and values. It returns false as the second argument if the key could not be constructed, e.g. if one of the keys does not match a field in the row. keys must be sorted in ascending order.

func (*Row) Reset

func (r *Row) Reset()

Reset clears the row of all data, preserving allocated memory.

type RowMeasure

type RowMeasure interface {
	Measure
	RowWriter() RowWriterFunc
}

type RowWriterFunc

type RowWriterFunc func(buf []byte, init bool) error

type Schema

type Schema struct {
	Name           string
	Filter         Filter
	Keys           []KeySpec
	Measures       []MeasureSpec // Field-level measures
	RecordMeasures []RowMeasure  // Record-level measures
}

A Schema defines the structure of a collation.

func (*Schema) Compile

func (s *Schema) Compile() (Collator, error)

type Sum

type Sum struct{}

Sum is a precise sum of continuous observations over all time.

func (Sum) ContReader

func (Sum) ContReader() ContReaderFunc

func (Sum) ContWriter

func (Sum) ContWriter() ContWriterFunc

func (Sum) Name

func (Sum) Name() string

func (Sum) Size

func (Sum) Size() int

type Variance

type Variance struct{}

Variance is a precise variance of continuous observations over all time.

func (Variance) ContReader

func (Variance) ContReader() ContReaderFunc

func (Variance) ContWriter

func (Variance) ContWriter() ContWriterFunc

func (Variance) Name

func (Variance) Name() string

func (Variance) Size

func (Variance) Size() int

Jump to

Keyboard shortcuts

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