accumulators

package
v0.0.0-...-bb56650 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package accumulators provides aggregation accumulator operators. Accumulators are different from other operators as they perform operations on a group of documents rather than a single document. They are used only in small subset of available stages (like `$group`).

Accumulators that can be used outside of accumulation with different behaviour (like `$sum`), should be stored in both operators and accumulators packages.

Index

Constants

This section is empty.

Variables

View Source
var Accumulators = map[string]newAccumulatorFunc{

	"$count": newCount,
	"$sum":   newSum,
}

Accumulators maps all aggregation accumulators.

Functions

This section is empty.

Types

type Accumulator

type Accumulator interface {
	// Accumulate documents and returns the result of applying operator.
	// It should always close iterator.
	Accumulate(iter types.DocumentsIterator) (any, error)
}

Accumulator is a common interface for aggregation accumulation operators.

func NewAccumulator

func NewAccumulator(stage, key string, value any) (Accumulator, error)

NewAccumulator returns accumulator for provided value.

Jump to

Keyboard shortcuts

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