consolidators

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// BufferSteps is the default number of steps to buffer.
	BufferSteps = 32
)

Variables

This section is empty.

Functions

func FromIdentTagIteratorToTags

func FromIdentTagIteratorToTags(
	identTags ident.TagIterator,
	tagOptions models.TagOptions,
) (models.Tags, error)

FromIdentTagIteratorToTags converts ident tags to coordinator tags.

func MustIdentTagIteratorToTags added in v1.2.0

func MustIdentTagIteratorToTags(
	identTags ident.TagIterator,
	tagOptions models.TagOptions,
) models.Tags

MustIdentTagIteratorToTags converts ident tags to coordinator tags.

func NewLimitError added in v1.2.0

func NewLimitError(msg string) error

NewLimitError returns a limit error so that it's the same type as the query limit error returned from a single database instance to receive the same error behavior as a database limit error.

func TakeLast added in v1.2.0

func TakeLast(values []ts.Datapoint) float64

TakeLast is a consolidation function which takes the last datapoint.

Types

type CompleteTagsResult added in v0.15.5

type CompleteTagsResult struct {
	// CompleteNameOnly indicates if the tags in this result are expected to have
	// both names and values, or only names.
	CompleteNameOnly bool
	// CompletedTag is a list of completed tags.
	CompletedTags []CompletedTag
	// Metadata describes any metadata for the operation.
	Metadata block.ResultMetadata
}

CompleteTagsResult represents a set of autocompleted tag names and values

type CompleteTagsResultBuilder added in v0.15.5

type CompleteTagsResultBuilder interface {
	// Add appends an incoming CompleteTagsResult.
	Add(*CompleteTagsResult) error
	// Build builds a completed tag result.
	Build() CompleteTagsResult
}

CompleteTagsResultBuilder is a builder that accumulates and deduplicates incoming CompleteTagsResult values.

func NewCompleteTagsResultBuilder added in v0.15.5

func NewCompleteTagsResultBuilder(
	nameOnly bool,
	opts models.TagOptions,
) CompleteTagsResultBuilder

NewCompleteTagsResultBuilder creates a new complete tags result builder.

type CompletedTag added in v0.15.5

type CompletedTag struct {
	// Name the name of the tag.
	Name []byte
	// Values is a set of possible values for the tag.
	// NB: if the parent CompleteTagsResult is set to CompleteNameOnly, this is
	// expected to be empty.
	Values [][]byte
}

CompletedTag represents a tag retrieved by a complete tags query.

type ConsolidationFunc added in v1.2.0

type ConsolidationFunc func(datapoints []ts.Datapoint) float64

ConsolidationFunc consolidates a bunch of datapoints into a single float value.

type LimitOptions added in v1.2.0

type LimitOptions struct {
	Limit             int
	RequireExhaustive bool
}

LimitOptions specifies the limits when accumulating results in consolidators.

type MatchOptions

type MatchOptions struct {
	// MatchType is the equality matching type by which to compare series.
	MatchType MatchType
}

MatchOptions are multi fetch matching options.

type MatchType

type MatchType uint

MatchType is a equality match type.

const (
	// MatchIDs matches series based on ID only.
	MatchIDs MatchType = iota
	// MatchTags matcher series based on tags.
	MatchTags
)

func (MatchType) String

func (t MatchType) String() string

func (*MatchType) UnmarshalYAML

func (t *MatchType) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals an ExtendedMetricsType into a valid type from string.

type MultiFetchResult

type MultiFetchResult interface {
	// Add appends series fetch results to the accumulator.
	Add(r MultiFetchResults)

	// AddWarnings appends warnings to the accumulator.
	AddWarnings(warnings ...block.Warning)

	Results() []MultiFetchResults

	// FinalResult returns a series fetch result containing deduplicated series
	// iterators and their metadata, and any errors encountered.
	FinalResult() (SeriesFetchResult, error)

	// FinalResultWithAttrs returns a series fetch result containing deduplicated series
	// iterators and their metadata, as well as any attributes corresponding to
	// these results, and any errors encountered.
	FinalResultWithAttrs() (SeriesFetchResult, []storagemetadata.Attributes, error)

	// Close releases all resources held by this accumulator.
	Close() error
}

MultiFetchResult is a deduping accumalator for series iterators that allows merging using a given strategy.

func NewMultiFetchResult

func NewMultiFetchResult(
	fanout QueryFanoutType,
	pools encoding.IteratorPools,
	opts MatchOptions,
	tagOpts models.TagOptions,
	limitOpts LimitOptions,
) MultiFetchResult

NewMultiFetchResult builds a new multi fetch result.

type MultiFetchResults added in v1.2.0

type MultiFetchResults struct {
	SeriesIterators encoding.SeriesIterators
	Metadata        block.ResultMetadata
	Attrs           storagemetadata.Attributes
	Err             error
}

MultiFetchResults is a deduping accumalator for series iterators that allows merging using a given strategy.

type MultiFetchTagsResult

type MultiFetchTagsResult interface {
	// Add adds tagged ID iterators to the accumulator.
	Add(
		newIterator client.TaggedIDsIterator,
		meta block.ResultMetadata,
		err error,
	)
	// FinalResult returns a deduped list of tag iterators with
	// corresponding series IDs.
	FinalResult() (TagResult, error)
	// Close releases all resources held by this accumulator.
	Close() error
}

MultiFetchTagsResult is a deduping accumalator for tag iterators.

func NewMultiFetchTagsResult

func NewMultiFetchTagsResult(opts models.TagOptions) MultiFetchTagsResult

NewMultiFetchTagsResult builds a new multi fetch tags result.

type MultiTagResult

type MultiTagResult struct {
	// ID is the series ID.
	ID ident.ID
	// Iter is the tag iterator for the series.
	Iter ident.TagIterator
}

MultiTagResult represents a tag iterator with its string ID.

type QueryFanoutType

type QueryFanoutType uint

QueryFanoutType is a query fanout type.

const (
	// NamespaceInvalid indicates there is no valid namespace.
	NamespaceInvalid QueryFanoutType = iota
	// NamespaceCoversAllQueryRange indicates the given namespace covers
	// the entire query range.
	NamespaceCoversAllQueryRange
	// NamespaceCoversPartialQueryRange indicates the given namespace covers
	// a partial query range.
	NamespaceCoversPartialQueryRange
)

func (QueryFanoutType) String

func (t QueryFanoutType) String() string

type SeriesFetchResult

type SeriesFetchResult struct {
	// Metadata is the set of metadata associated with the fetch result.
	Metadata block.ResultMetadata
	// contains filtered or unexported fields
}

SeriesFetchResult is a fetch result with associated metadata.

func NewEmptyFetchResult

func NewEmptyFetchResult(
	meta block.ResultMetadata,
) SeriesFetchResult

NewEmptyFetchResult creates a new empty series fetch result.

func NewSeriesFetchResult

func NewSeriesFetchResult(
	iters encoding.SeriesIterators,
	tags []*models.Tags,
	meta block.ResultMetadata,
) (SeriesFetchResult, error)

NewSeriesFetchResult creates a new series fetch result using the given iterators.

func (*SeriesFetchResult) Close

func (r *SeriesFetchResult) Close()

Close no-ops; these should be closed by the enclosing iterator.

func (*SeriesFetchResult) Count

func (r *SeriesFetchResult) Count() int

Count returns the total number of contained series iterators.

func (*SeriesFetchResult) IterTagsAtIndex

func (r *SeriesFetchResult) IterTagsAtIndex(
	idx int, tagOpts models.TagOptions,
) (encoding.SeriesIterator, models.Tags, error)

IterTagsAtIndex returns the tag iterator and tags at the given index.

func (*SeriesFetchResult) SeriesIterators

func (r *SeriesFetchResult) SeriesIterators() []encoding.SeriesIterator

SeriesIterators returns the series iterators.

func (*SeriesFetchResult) Verify

func (r *SeriesFetchResult) Verify() error

Verify verifies the fetch result is valid.

type SeriesLookbackConsolidator added in v1.2.0

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

SeriesLookbackConsolidator is a helper for consolidating a full single series. It has some differences with the step consolidator in that it collects points for a single series, and is reset when the next series needs to be consolidated.

func NewSeriesLookbackConsolidator added in v1.2.0

func NewSeriesLookbackConsolidator(
	lookbackDuration, stepSize time.Duration,
	startTime xtime.UnixNano,
	fn ConsolidationFunc,
) *SeriesLookbackConsolidator

NewSeriesLookbackConsolidator creates a single value consolidator used for series iteration with a given lookback.

func (*SeriesLookbackConsolidator) AddPoint added in v1.2.0

func (c *SeriesLookbackConsolidator) AddPoint(
	dp ts.Datapoint,
)

AddPoint adds a datapoint if it's within the valid time period; otherwise drops it silently, which is fine for consolidation.

func (*SeriesLookbackConsolidator) ConsolidateAndMoveToNext added in v1.2.0

func (c *SeriesLookbackConsolidator) ConsolidateAndMoveToNext() float64

ConsolidateAndMoveToNext consolidates the current values and moves the consolidator to the next given value, purging stale values.

func (*SeriesLookbackConsolidator) Empty added in v1.2.0

func (c *SeriesLookbackConsolidator) Empty() bool

Empty returns true if there are no datapoints in the consolidator. It is used to let consumers of the consolidators shortcircuit logic.

func (*SeriesLookbackConsolidator) Reset added in v1.2.0

func (c *SeriesLookbackConsolidator) Reset(
	startTime xtime.UnixNano,
)

Reset purges all points from the consolidator. This should be called when moving to the next series to consolidate.

type StepCollector added in v1.2.0

type StepCollector interface {
	// AddPoint adds a datapoint to the current step it's within the valid time
	// period; otherwise drops it silently, which is fine for consolidation.
	AddPoint(ts.Datapoint)
	// BufferStep computes the currently collected step values.
	BufferStep()
	// BufferStepCount gives the number of remaining buffer steps.
	BufferStepCount() int
}

StepCollector is implemented by any accumulators or consolidators working on stepwise iteration.

type StepLookbackAccumulator added in v1.2.0

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

StepLookbackAccumulator is a helper for accumulating series in a step-wise fashion. It takes a 'step' of values, which represents a vertical slice of time across a list of series, and accumulates them when a valid step has been reached.

func NewStepLookbackAccumulator added in v1.2.0

func NewStepLookbackAccumulator(
	lookbackDuration, stepSize time.Duration,
	startTime xtime.UnixNano,
) *StepLookbackAccumulator

NewStepLookbackAccumulator creates an accumulator used for step iteration across a series list with a given lookback.

func (*StepLookbackAccumulator) AccumulateAndMoveToNext added in v1.2.0

func (c *StepLookbackAccumulator) AccumulateAndMoveToNext() []xts.Datapoint

AccumulateAndMoveToNext consolidates the current values and moves the consolidator to the next given value, purging stale values.

func (*StepLookbackAccumulator) AddPoint added in v1.2.0

func (c *StepLookbackAccumulator) AddPoint(dp ts.Datapoint)

AddPoint adds a datapoint to a given step if it's within the valid time period; otherwise drops it silently, which is fine for accumulation.

func (*StepLookbackAccumulator) BufferStep added in v1.2.0

func (c *StepLookbackAccumulator) BufferStep()

BufferStep adds viable points to the next unconsumed buffer step.

func (*StepLookbackAccumulator) BufferStepCount added in v1.2.0

func (c *StepLookbackAccumulator) BufferStepCount() int

BufferStepCount indicates how many accumulated points are still unconsumed.

type StepLookbackConsolidator added in v1.2.0

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

StepLookbackConsolidator is a helper for consolidating series in a step-wise fashion. It takes a 'step' of values, which represents a vertical slice of time across a list of series, and consolidates when a valid step has been reached.

func NewStepLookbackConsolidator added in v1.2.0

func NewStepLookbackConsolidator(
	lookbackDuration, stepSize time.Duration,
	startTime xtime.UnixNano,
	fn ConsolidationFunc,
) *StepLookbackConsolidator

NewStepLookbackConsolidator creates a multivalue consolidator used for step iteration across a series list with a given lookback.

func (*StepLookbackConsolidator) AddPoint added in v1.2.0

func (c *StepLookbackConsolidator) AddPoint(dp ts.Datapoint)

AddPoint adds a datapoint to a given step if it's within the valid time period; otherwise drops it silently, which is fine for consolidation.

func (*StepLookbackConsolidator) BufferStep added in v1.2.0

func (c *StepLookbackConsolidator) BufferStep()

BufferStep adds viable points to the next unconsumed buffer step.

func (*StepLookbackConsolidator) BufferStepCount added in v1.2.0

func (c *StepLookbackConsolidator) BufferStepCount() int

BufferStepCount indicates how many accumulated points are still unconsumed.

func (*StepLookbackConsolidator) ConsolidateAndMoveToNext added in v1.2.0

func (c *StepLookbackConsolidator) ConsolidateAndMoveToNext() float64

ConsolidateAndMoveToNext consolidates the current values and moves the consolidator to the next given value, purging stale values.

type TagResult

type TagResult struct {
	// Metadata is the set of metadata associated with the fetch result.
	Metadata block.ResultMetadata
	// Tags is the list of tags for the result.
	Tags []MultiTagResult
}

TagResult is a fetch tag result with associated metadata.

Jump to

Keyboard shortcuts

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