Documentation
¶
Index ¶
- Variables
- func GetAggregationItemType(aggregation string) (parser.ItemType, bool)
- type Aggregation
- type AggregationGroup
- type AggregationGroupFactory
- type AvgAggregationGroup
- type CountGroupAggregationGroup
- type MinMaxAggregationGroup
- type SeriesToGroupLabelsBytesFunc
- type StddevStdvarAggregationGroup
- type SumAggregationGroup
Constants ¶
This section is empty.
Variables ¶
var AggregationGroupFactories = map[parser.ItemType]AggregationGroupFactory{ parser.AVG: func() AggregationGroup { return &AvgAggregationGroup{} }, parser.COUNT: func() AggregationGroup { return NewCountGroupAggregationGroup(true) }, parser.GROUP: func() AggregationGroup { return NewCountGroupAggregationGroup(false) }, parser.MAX: func() AggregationGroup { return NewMinMaxAggregationGroup(true) }, parser.MIN: func() AggregationGroup { return NewMinMaxAggregationGroup(false) }, parser.STDDEV: func() AggregationGroup { return NewStddevStdvarAggregationGroup(true) }, parser.STDVAR: func() AggregationGroup { return NewStddevStdvarAggregationGroup(false) }, parser.SUM: func() AggregationGroup { return &SumAggregationGroup{} }, }
Functions ¶
Types ¶
type Aggregation ¶
type Aggregation struct { Inner types.InstantVectorOperator TimeRange types.QueryTimeRange Grouping []string // If this is a 'without' aggregation, NewAggregation will ensure that this slice contains __name__. Without bool MemoryConsumptionTracker *limiting.MemoryConsumptionTracker Annotations *annotations.Annotations // contains filtered or unexported fields }
func NewAggregation ¶
func NewAggregation( inner types.InstantVectorOperator, timeRange types.QueryTimeRange, grouping []string, without bool, op parser.ItemType, memoryConsumptionTracker *limiting.MemoryConsumptionTracker, annotations *annotations.Annotations, expressionPosition posrange.PositionRange, ) (*Aggregation, error)
func (*Aggregation) Close ¶
func (a *Aggregation) Close()
func (*Aggregation) ExpressionPosition ¶
func (a *Aggregation) ExpressionPosition() posrange.PositionRange
func (*Aggregation) NextSeries ¶
func (a *Aggregation) NextSeries(ctx context.Context) (types.InstantVectorSeriesData, error)
func (*Aggregation) SeriesMetadata ¶
func (a *Aggregation) SeriesMetadata(ctx context.Context) ([]types.SeriesMetadata, error)
type AggregationGroup ¶
type AggregationGroup interface { // AccumulateSeries takes in a series as part of the group AccumulateSeries(data types.InstantVectorSeriesData, timeRange types.QueryTimeRange, memoryConsumptionTracker *limiting.MemoryConsumptionTracker, emitAnnotationFunc types.EmitAnnotationFunc) error // ComputeOutputSeries does any final calculations and returns the grouped series data ComputeOutputSeries(timeRange types.QueryTimeRange, memoryConsumptionTracker *limiting.MemoryConsumptionTracker) (types.InstantVectorSeriesData, bool, error) }
AggregationGroup accumulates series that have been grouped together and computes the output series data.
type AggregationGroupFactory ¶
type AggregationGroupFactory func() AggregationGroup
type AvgAggregationGroup ¶
type AvgAggregationGroup struct {
// contains filtered or unexported fields
}
func (*AvgAggregationGroup) AccumulateSeries ¶
func (g *AvgAggregationGroup) AccumulateSeries(data types.InstantVectorSeriesData, timeRange types.QueryTimeRange, memoryConsumptionTracker *limiting.MemoryConsumptionTracker, emitAnnotationFunc types.EmitAnnotationFunc) error
func (*AvgAggregationGroup) ComputeOutputSeries ¶
func (g *AvgAggregationGroup) ComputeOutputSeries(timeRange types.QueryTimeRange, memoryConsumptionTracker *limiting.MemoryConsumptionTracker) (types.InstantVectorSeriesData, bool, error)
type CountGroupAggregationGroup ¶
type CountGroupAggregationGroup struct {
// contains filtered or unexported fields
}
func NewCountGroupAggregationGroup ¶
func NewCountGroupAggregationGroup(count bool) *CountGroupAggregationGroup
count represents whether this aggregation is `count` (true), or `group` (false)
func (*CountGroupAggregationGroup) AccumulateSeries ¶
func (g *CountGroupAggregationGroup) AccumulateSeries(data types.InstantVectorSeriesData, timeRange types.QueryTimeRange, memoryConsumptionTracker *limiting.MemoryConsumptionTracker, _ types.EmitAnnotationFunc) error
func (*CountGroupAggregationGroup) ComputeOutputSeries ¶
func (g *CountGroupAggregationGroup) ComputeOutputSeries(timeRange types.QueryTimeRange, memoryConsumptionTracker *limiting.MemoryConsumptionTracker) (types.InstantVectorSeriesData, bool, error)
type MinMaxAggregationGroup ¶
type MinMaxAggregationGroup struct {
// contains filtered or unexported fields
}
func NewMinMaxAggregationGroup ¶
func NewMinMaxAggregationGroup(max bool) *MinMaxAggregationGroup
max represents whether this aggregation is `max` (true), or `min` (false)
func (*MinMaxAggregationGroup) AccumulateSeries ¶
func (g *MinMaxAggregationGroup) AccumulateSeries(data types.InstantVectorSeriesData, timeRange types.QueryTimeRange, memoryConsumptionTracker *limiting.MemoryConsumptionTracker, emitAnnotation types.EmitAnnotationFunc) error
func (*MinMaxAggregationGroup) ComputeOutputSeries ¶
func (g *MinMaxAggregationGroup) ComputeOutputSeries(timeRange types.QueryTimeRange, memoryConsumptionTracker *limiting.MemoryConsumptionTracker) (types.InstantVectorSeriesData, bool, error)
type SeriesToGroupLabelsBytesFunc ¶
SeriesToGroupLabelsBytesFunc is a function that computes a string-like representation of the output group labels for the given input series.
It returns a byte slice rather than a string to make it possible to avoid unnecessarily allocating a string.
The byte slice returned may contain non-printable characters.
Why not just use the labels.Labels computed by the seriesToGroupLabelsFunc and call String() on it?
Most of the time, we don't need the labels.Labels instance, as we expect there are far fewer output groups than input series, and we only need the labels.Labels instance once per output group. However, we always need to compute the string-like representation for each input series, so we can look up its corresponding output group. And we can do this without allocating a string by returning just the bytes that make up the string. There's not much point in using the hash of the group labels as we always need the string (or the labels.Labels) to ensure there are no hash collisions - so we might as well just go straight to the string-like representation.
Furthermore, labels.Labels.String() doesn't allow us to reuse the buffer used when producing the string or to return a byte slice, whereas this method does. This saves us allocating a new buffer and string for every single input series, which has a noticeable performance impact.
func GroupLabelsBytesFunc ¶
func GroupLabelsBytesFunc(grouping []string, without bool) SeriesToGroupLabelsBytesFunc
type StddevStdvarAggregationGroup ¶
type StddevStdvarAggregationGroup struct {
// contains filtered or unexported fields
}
func NewStddevStdvarAggregationGroup ¶
func NewStddevStdvarAggregationGroup(stddev bool) *StddevStdvarAggregationGroup
stddev represents whether this aggregation is `stddev` (true), or `stdvar` (false)
func (*StddevStdvarAggregationGroup) AccumulateSeries ¶
func (g *StddevStdvarAggregationGroup) AccumulateSeries(data types.InstantVectorSeriesData, timeRange types.QueryTimeRange, memoryConsumptionTracker *limiting.MemoryConsumptionTracker, emitAnnotation types.EmitAnnotationFunc) error
func (*StddevStdvarAggregationGroup) ComputeOutputSeries ¶
func (g *StddevStdvarAggregationGroup) ComputeOutputSeries(timeRange types.QueryTimeRange, memoryConsumptionTracker *limiting.MemoryConsumptionTracker) (types.InstantVectorSeriesData, bool, error)
type SumAggregationGroup ¶
type SumAggregationGroup struct {
// contains filtered or unexported fields
}
func (*SumAggregationGroup) AccumulateSeries ¶
func (g *SumAggregationGroup) AccumulateSeries(data types.InstantVectorSeriesData, timeRange types.QueryTimeRange, memoryConsumptionTracker *limiting.MemoryConsumptionTracker, emitAnnotationFunc types.EmitAnnotationFunc) error
func (*SumAggregationGroup) ComputeOutputSeries ¶
func (g *SumAggregationGroup) ComputeOutputSeries(timeRange types.QueryTimeRange, memoryConsumptionTracker *limiting.MemoryConsumptionTracker) (types.InstantVectorSeriesData, bool, error)