aggregation

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownSampling

func DownSampling(
	source, target timeutil.SlotRange, ratio uint16, baseSlot int, getter encoding.TSDValueGetter,
	emitValue func(targetPos int, value float64),
)

DownSampling merges field data from source time range => target time range, for example: source range[5,182]=>target range[0,6], ratio:30, source interval:10s, target interval:5min.

func DownSamplingMultiSeriesInto

func DownSamplingMultiSeriesInto(
	target timeutil.SlotRange, ratio uint16, baseSlot uint16,
	fieldType field.Type, decoders []*encoding.TSDDecoder,
	emitValue func(targetPos int, value float64),
)

DownSamplingMultiSeriesInto merges field data from source time range => target time range, data will be merged into DownSamplingResult for example: source range[5,182]=>target range[0,6], ratio:30, source interval:10s, target interval:5min.

Types

type Aggregator

type Aggregator struct {
	DownSampling AggregatorSpec
	Aggregator   AggregatorSpec
}

Aggregator represents aggregator spec for down sampling/aggregator.

type AggregatorSpec

type AggregatorSpec interface {
	// FieldName returns field name.
	FieldName() field.Name
	// GetFieldType sets field type
	GetFieldType() field.Type
	// AddFunctionType adds function type for down sampling.
	AddFunctionType(funcType function.FuncType)
	// Functions returns function types for down sampling.
	Functions() map[function.FuncType]function.FuncType
}

AggregatorSpec represents aggregator spec.

func NewAggregatorSpec

func NewAggregatorSpec(fieldName field.Name, fieldType field.Type) AggregatorSpec

NewAggregatorSpec creates a AggregatorSpec.

type AggregatorSpecs

type AggregatorSpecs []AggregatorSpec

AggregatorSpecs represents aggregator spec slice.

type Expression

type Expression interface {
	// Eval evaluates the select item's expression.
	Eval(timeSeries series.GroupedIterator)
	// ResultSet returns the eval result, returns field name(alias) => series data.
	ResultSet() map[string]*collections.FloatArray
	// Reset resets the Expression context for reusing.
	Reset()
}

Expression represents Expression eval like math calc, function call etc. 1. prepare field store based on time series iterator 2. eval the Expression 3. build result set

func NewExpression

func NewExpression(timeRange timeutil.TimeRange, interval int64, selectItems []stmt.Expr) Expression

NewExpression creates an Expression instance.

type FieldAggregates

type FieldAggregates []SeriesAggregator

FieldAggregates represents aggregator which aggregates fields of a time series

func NewFieldAggregates

func NewFieldAggregates(
	queryInterval timeutil.Interval,
	intervalRatio int,
	queryTimeRange timeutil.TimeRange,
	aggSpecs AggregatorSpecs,
) FieldAggregates

NewFieldAggregates creates the field aggregates based on aggregator specs and query time range. NOTE: if it does down sampling aggregator, aggregator specs must be in order by field id.

func (FieldAggregates) Reset

func (agg FieldAggregates) Reset()

Reset resets the aggregator's context for reusing

func (FieldAggregates) ResultSet

func (agg FieldAggregates) ResultSet(tags string) series.GroupedIterator

ResultSet returns the result set of aggregator

type FieldAggregator

type FieldAggregator interface {
	// Aggregate aggregates the field series into current aggregator.
	Aggregate(it series.FieldIterator)
	// AggregateBySlot aggregates the field series into current aggregator.
	AggregateBySlot(slot int, value float64)
	// ResultSet returns the result set of field aggregator.
	ResultSet() (startTime int64, it series.FieldIterator)
	// contains filtered or unexported methods
}

FieldAggregator represents a field aggregator, aggregator the field series which with same field id.

func NewFieldAggregator

func NewFieldAggregator(aggSpec AggregatorSpec, segmentStartTime int64, start, end int) FieldAggregator

NewFieldAggregator creates a field aggregator, time range 's start and end is index based on segment start time and interval. e.g. segment start time = 20190905 10:00:00, start = 10, end = 50, interval = 10 seconds, real query time range {20190905 10:01:40 ~ 20190905 10:08:20}

type GroupingAggregator

type GroupingAggregator interface {
	// Aggregate aggregates the time series data
	Aggregate(it series.GroupedIterator)
	// ResultSet returns the result set of aggregator
	ResultSet() series.GroupedIterators
	// TimeRange returns the time range of aggregator.
	TimeRange() timeutil.TimeRange
	// Interval returns the time interval of aggregator.
	Interval() timeutil.Interval
	// Fields returns all fields.
	Fields() []field.Name
}

GroupingAggregator represents an aggregator which merges time series and does grouping if need.

func NewGroupingAggregator

func NewGroupingAggregator(
	interval timeutil.Interval,
	intervalRatio int,
	timeRange timeutil.TimeRange,
	aggSpecs AggregatorSpecs,
) GroupingAggregator

NewGroupingAggregator creates a grouping aggregator

type OrderBy

type OrderBy interface {
	// Push pushes row into container.
	Push(row Row)
	// ResultSet returns result set of order by.
	ResultSet() []Row
}

OrderBy represents order by container.

func NewResultLimiter

func NewResultLimiter(limit int) OrderBy

NewResultLimiter creates a size limit container.

func NewTopNOrderBy

func NewTopNOrderBy(orderByItems []*OrderByItem, topN int) OrderBy

NewTopNOrderBy creates a topNOrderBy container instance.

type OrderByItem

type OrderByItem struct {
	Expr     *stmt.OrderByExpr
	Name     string
	FuncType function.FuncType
	Desc     bool
}

OrderByItem represents the order by expr item.

type OrderByRow

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

OrderByRow represents row for order by, implements Row interface.

func (*OrderByRow) GetValue

func (r *OrderByRow) GetValue(fieldName string, funcType function.FuncType) float64

GetValue returns the value of aggregation for this series based on given field name/function type.

func (*OrderByRow) ResultSet

func (r *OrderByRow) ResultSet() (tags string, fields map[string]*collections.FloatArray)

ResultSet returns the resutl set of series(tags/fields).

type Row

type Row interface {
	// GetValue returns the value based on given field name and function type.
	GetValue(fieldName string, funcType function.FuncType) float64
	// ResultSet returns the result set(tags/fields).
	ResultSet() (tags string, fields map[string]*collections.FloatArray)
}

Row represents the series data for one group.

func NewOrderByRow

func NewOrderByRow(tags string, fields map[string]*collections.FloatArray) Row

NewOrderByRow creates a OrderByRow instance.

type SeriesAggregator

type SeriesAggregator interface {
	// FieldName returns field name
	FieldName() field.Name
	// GetFieldType returns field type
	GetFieldType() field.Type
	// GetAggregator gets field aggregator by start time of query for the segment.
	GetAggregator(segmentStartTime int64) FieldAggregator

	// GetAggregates returns all field aggregators.
	GetAggregates() []FieldAggregator
	// ResultSet returns the result set of series aggregator.
	ResultSet() series.Iterator
	// Reset resets the aggregator's context for reusing.
	Reset()
	// contains filtered or unexported methods
}

SeriesAggregator represents a series aggregator which aggregates one field of a time series

func NewMergeSeriesAggregator added in v0.2.4

func NewMergeSeriesAggregator(
	queryInterval timeutil.Interval,
	intervalRatio int,
	queryTimeRange timeutil.TimeRange,
	aggSpec AggregatorSpec,
) SeriesAggregator

NewMergeSeriesAggregator creates a merge series aggregator.

func NewSeriesAggregator

func NewSeriesAggregator(
	queryInterval timeutil.Interval,
	intervalRatio int,
	queryTimeRange timeutil.TimeRange,
	aggSpec AggregatorSpec,
) SeriesAggregator

NewSeriesAggregator creates a series aggregator.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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