orderings

package
v0.0.0-...-a69e935 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: Apache-2.0, MIT Imports: 6 Imported by: 13

Documentation

Index

Constants

View Source
const (
	// EntitySource means that the metrics comes from an entity.
	EntitySource = Source("entity")

	// GroupSource means that the metrics comes from an group.
	GroupSource = Source("group")
)

Variables

This section is empty.

Functions

func Concatenate

func Concatenate(subExpressions ...placement.Ordering) placement.Ordering

Concatenate will take a list of orderings and then make a concatenation that will behave like a lexicographic ordering.

func Constant

func Constant(constant float64) placement.Ordering

Constant will return a tuple score which will always return a tuple of length one with the given constant.

func Inverse

func Inverse(subExpression placement.Ordering) placement.Ordering

Inverse will invert the given tuple.

func Label

func Label(scope, pattern *labels.Label) placement.Ordering

Label will create an ordering which will order groups based on the number of their labels matching the given pattern.

func Map

func Map(mapping *Mapping, subExpression placement.Ordering) placement.Ordering

Map will change the tuple according to which bucket each entry of the tuple falls.

func Metric

func Metric(source Source, metricType metrics.Type) placement.Ordering

Metric will create an ordering which will order groups based on their value of the given metric type.

func Multiply

func Multiply(subExpressions ...placement.Ordering) placement.Ordering

Multiply will take the tuples of the sub expressions and return a tuple which will have the length of the smallest tuple returned from the sub expressions where each entry is the multiplication of the corresponding entry in the tuple from the sub expressions.

func Negate

func Negate(subExpression placement.Ordering) placement.Ordering

Negate will negate the given tuple.

func Relation

func Relation(scope, pattern *labels.Label) placement.Ordering

Relation will create an ordering which will order groups based on the number of their relations matching the given pattern.

func Sum

func Sum(subExpressions ...placement.Ordering) placement.Ordering

Sum will take the tuples of the sub expressions and return a tuple which will have the length of the smallest tuple returned from the sub expressions where each entry is the summation of the corresponding entry in the tuple from the sub expressions.

Types

type Bucket

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

Bucket represents an interval that maps to a given value.

func NewBucket

func NewBucket(start, end *Endpoint, value float64) *Bucket

NewBucket creates a new bucket from a start and end point and a value that the bucket should have.

func (*Bucket) Contains

func (bucket *Bucket) Contains(value float64) bool

Contains returns true iff the given value is contained in the bucket.

func (*Bucket) End

func (bucket *Bucket) End() *Endpoint

End returns the end endpoint of the bucket.

func (*Bucket) Start

func (bucket *Bucket) Start() *Endpoint

Start returns the start endpoint of the bucket.

func (*Bucket) String

func (bucket *Bucket) String() string

String will return a string representation of the interval of the bucket.

func (*Bucket) Validate

func (bucket *Bucket) Validate() error

Validate will check if the bucket is valid, i.e. the start is before the end and the bucket is non-empty.

func (*Bucket) Value

func (bucket *Bucket) Value() float64

Value returns the value of the bucket.

type ConcatenateCustom

type ConcatenateCustom struct {
	SubExpressions []placement.Ordering
}

ConcatenateCustom can create a tuple of floats which is the concatenation of tuples created in the sub-expressions.

func (*ConcatenateCustom) Tuple

func (custom *ConcatenateCustom) Tuple(group *placement.Group, scopeSet *placement.ScopeSet, entity *placement.Entity) []float64

Tuple returns a tuple of floats created from the group, scope groups and the entity.

type ConstantCustom

type ConstantCustom struct {
	Constant float64
}

ConstantCustom creates a tuple of one value which is always the given constant.

func (*ConstantCustom) Tuple

func (custom *ConstantCustom) Tuple(group *placement.Group, scopeSet *placement.ScopeSet, entity *placement.Entity) []float64

Tuple returns a tuple of floats created from the group, scope groups and the entity.

type Endpoint

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

Endpoint represents an endpoint in an interval which can be open or close.

func NewEndpoint

func NewEndpoint(value float64, open bool) *Endpoint

NewEndpoint creates a new endpoint from a value and whatever the endpoint should be open or closed.

func (*Endpoint) Open

func (endpoint *Endpoint) Open() bool

Open returns true iff the endpoint is open, else it is closed.

func (*Endpoint) Value

func (endpoint *Endpoint) Value() float64

Value returns the value of the endpoint.

type InverseCustom

type InverseCustom struct {
	SubExpression placement.Ordering
}

InverseCustom can create a tuple of floats where each tuple entry is the inverse of the same tuple entry created in the sub-expression.

func (*InverseCustom) Tuple

func (custom *InverseCustom) Tuple(group *placement.Group, scopeSet *placement.ScopeSet, entity *placement.Entity) []float64

Tuple returns a tuple of floats created from the group, scope groups and the entity.

type LabelCustom

type LabelCustom struct {
	Scope   *labels.Label
	Pattern *labels.Label
}

LabelCustom can create a tuple of one float which is the number of occurrences of labels that match the pattern in the given scope.

func (*LabelCustom) Tuple

func (custom *LabelCustom) Tuple(group *placement.Group, scopeSet *placement.ScopeSet, entity *placement.Entity) []float64

Tuple returns a tuple of floats created from the group, scope groups and the entity.

type MapCustom

type MapCustom struct {
	Mapping       *Mapping
	SubExpression placement.Ordering
}

MapCustom creates a tuple from the sub-expression and maps each entry of the tuple to a different value according to the given mapping.

func (*MapCustom) Tuple

func (custom *MapCustom) Tuple(group *placement.Group, scopeSet *placement.ScopeSet, entity *placement.Entity) []float64

Tuple returns a tuple of floats created from the group, scope groups and the entity.

type Mapping

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

Mapping represents a mapping of an interval from ]-inf;inf[ onto a finite set of float values.

func NewMapping

func NewMapping(buckets ...*Bucket) (*Mapping, error)

NewMapping will create a new mapping from a list of buckets. The buckets will be checked to not overlap and to ensure that they cover the whole range [-inf;inf], if this is not the case an error is returned.

func (*Mapping) Buckets

func (mapping *Mapping) Buckets() []*Bucket

Buckets returns a copy of the list of buckets.

func (*Mapping) Map

func (mapping *Mapping) Map(value float64) float64

Map will map the given value into another value defined by the mapping.

type MetricCustom

type MetricCustom struct {
	Source     Source
	MetricType metrics.Type
}

MetricCustom can create a tuple of one float which is the value of the metric found in the given source.

func (*MetricCustom) Tuple

func (custom *MetricCustom) Tuple(group *placement.Group, scopeSet *placement.ScopeSet, entity *placement.Entity) []float64

Tuple returns a tuple of floats created from the group, scope groups and the entity.

type MultiplyCustom

type MultiplyCustom struct {
	SubExpressions []placement.Ordering
}

MultiplyCustom can create a tuple of floats which is the multiplication of tuples created in the sub-expressions. The resulting will have the same length as the shortest tuple returned in the sub-expressions and each entry will be the multiplication of the entries of the other tuples at the same index.

func (*MultiplyCustom) Tuple

func (custom *MultiplyCustom) Tuple(group *placement.Group, scopeSet *placement.ScopeSet, entity *placement.Entity) []float64

Tuple returns a tuple of floats created from the group, scope groups and the entity.

type NegateCustom

type NegateCustom struct {
	SubExpression placement.Ordering
}

NegateCustom can create a tuple of floats where each tuple entry is the negation of the same tuple entry created in the sub-expression.

func (*NegateCustom) Tuple

func (custom *NegateCustom) Tuple(group *placement.Group, scopeSet *placement.ScopeSet, entity *placement.Entity) []float64

Tuple returns a tuple of floats created from the group, scope groups and the entity.

type RelationCustom

type RelationCustom struct {
	Scope   *labels.Label
	Pattern *labels.Label
}

RelationCustom can create a tuple of one float which is the number of occurrences of relations that match the pattern in the given scope.

func (*RelationCustom) Tuple

func (custom *RelationCustom) Tuple(group *placement.Group, scopeSet *placement.ScopeSet, entity *placement.Entity) []float64

Tuple returns a tuple of floats created from the group, scope groups and the entity.

type Source

type Source string

Source represents the source where a metric used in a custom ordering comes from.

type SumCustom

type SumCustom struct {
	SubExpressions []placement.Ordering
}

SumCustom can create a tuple of floats which is the summation of tuples created in the sub-expressions. The resulting will have the same length as the shortest tuple returned in the sub-expressions and each entry will be the summation of the entries of the other tuples at the same index.

func (*SumCustom) Tuple

func (custom *SumCustom) Tuple(group *placement.Group, scopeSet *placement.ScopeSet, entity *placement.Entity) []float64

Tuple returns a tuple of floats created from the group, scope groups and the entity.

Jump to

Keyboard shortcuts

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