aggregations

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package aggregations provides aggregation pipelines.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPushdownQuery added in v0.9.4

func GetPushdownQuery(stagesDocs []any) *types.Document

GetPushdownQuery gets pushdown query for aggregation. When the first aggregation stage is $match, $match query is used for pushdown, otherwise nil is return.

func GetStatistics added in v1.0.0

func GetStatistics(stages []Stage) map[Statistic]struct{}

GetStatistics has the same idea as GetPushdownQuery: it returns a list of statistics that need to be fetched from the DB, because they are needed for one or more stages.

Types

type Accumulator added in v0.9.3

type Accumulator interface {
	// Accumulate documents and returns the result of applying accumulation operator.
	Accumulate(ctx context.Context, groupID any, in []*types.Document) (any, error)
}

Accumulator is a common interface for accumulation.

type Stage

type Stage interface {
	// Process applies an aggregate stage on `in` document, it could modify `in` in-place.
	Process(ctx context.Context, in []*types.Document) ([]*types.Document, error)

	// Type returns the type of the stage.
	Type() StageType
}

Stage is a common interface for all aggregation stages. TODO use iterators instead of slices of documents https://github.com/FerretDB/FerretDB/issues/1889.

func NewStage

func NewStage(stage *types.Document) (Stage, error)

NewStage creates a new aggregation stage.

type StageType added in v1.0.0

type StageType int

StageType is a type for aggregation stage types.

const (
	// StageTypeDocuments is a type for stages that process documents.
	StageTypeDocuments StageType = iota

	// StageTypeStats is a type for stages that process statistics and doesn't need documents.
	StageTypeStats
)

type Statistic added in v1.0.0

type Statistic int32

Statistic represents a statistic that can be fetched from the DB.

const (
	StatisticCount Statistic = iota
	StatisticLatency
	StatisticQueryExec
	StatisticStorage
)

List of statistics that can be fetched from the DB.

Jump to

Keyboard shortcuts

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