aggregate

package
v0.0.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsMap

func AsMap[In any, K comparable, V any](prevStage stages.Stage[In], mapFunc functions.MapFunc[In, types.Tuple[K, V]], confs ...configs.StageConfig) (*map[K]V, error)

AsMap is a sync aggregation function that reduces all the elements from the stage channel to a map. This function returns error if the pipeline is interrupted before the stage finishes. The error is obtained internally by calling the `context.Err()` function.

Only the comparable types are supported as a map key.

This is a final stage function, which means that it leads to the end of the pipeline. If you need to set up the pipeline, use functions from the [pipeline] package. If you need to make more transformations, use functions from the [transform] package instead.

If you need to reduce the elements to a slice, use AsSlice instead. If you need to reduce the elements to a sorted slice, use Sort or SortDesc instead. If you need to reduce the elements to a multimap, use AsMultiMap instead. If you need to reduce the elements to a single value, use Sum, Avg, Max, Min, Count or Reduce instead. If you need the async version of this function, use the asyncaggregate.AsMap instead.

func AsMultiMap

func AsMultiMap[In any, K comparable, V any](prevStage stages.Stage[In], mapFunc functions.MapFunc[In, types.Tuple[K, V]], confs ...configs.StageConfig) (*map[K][]V, error)

AsMultiMap is a sync aggregation function that reduces all the elements from the stage channel to a multimap. This function returns error if the pipeline is interrupted before the stage finishes. The error is obtained internally by calling the `context.Err()` function.

Only the comparable types are supported as a map key.

This is a final stage function, which means that it leads to the end of the pipeline. If you need to set up the pipeline, use functions from the [pipeline] package. If you need to make more transformations, use functions from the [transform] package instead.

If you need to reduce the elements to a slice, use AsSlice instead. If you need to reduce the elements to a sorted slice, use Sort or SortDesc instead. If you need to reduce the elements to a map, use AsMap instead. If you need to reduce the elements to a single value, use Sum, Avg, Max, Min, Count or Reduce instead. If you need the async version of this function, use the asyncaggregate.AsMultiMap instead.

func AsSlice

func AsSlice[In any](prevStage stages.Stage[In], confs ...configs.StageConfig) (*[]In, error)

AsSlice is a sync aggregation function that reduces all the elements from the stage channel to a slice. This function returns error if the pipeline is interrupted before the stage finishes. The error is obtained internally by calling the `context.Err()` function.

This is a final stage function, which means that it leads to the end of the pipeline. If you need to set up the pipeline, use functions from the [pipeline] package. If you need to make more transformations, use functions from the [transform] package instead.

If you need to reduce the elements to a sorted slice, use Sort or SortDesc instead. If you need to reduce the elements to a map, use AsMap instead. If you need to reduce the elements to a multimap, use AsMultiMap instead. If you need to reduce the elements to a single value, use Sum, Avg, Max, Min, Count or Reduce instead. If you need the async version of this function, use the asyncaggregate.AsSlice instead.

func Avg

func Avg[In types.Number](prevStage stages.Stage[In], confs ...configs.StageConfig) (*float64, error)

Avg is a sync aggregation function that calculates the average of all the elements from the stage channel. This function returns error if the pipeline is interrupted before the stage finishes. The error is obtained internally by calling the `context.Err()` function.

If you need to calculate the average of complex numbers, use AvgComplexType instead. If you need the async version of this function, use the asyncaggregate.Avg instead.

func AvgComplexType

func AvgComplexType[In types.ComplexNumber](prevStage stages.Stage[In], confs ...configs.StageConfig) (*complex128, error)

AvgComplexType is a sync aggregation function that calculates the average of all the elements from the stage channel. This function returns error if the pipeline is interrupted before the stage finishes. The error is obtained internally by calling the `context.Err()` function.

This is a final stage function, which means that it leads to the end of the pipeline. If you need to set up the pipeline, use functions from the [pipeline] package. If you need to make more transformations, use functions from the [transform] package instead.

If you need to calculate the average of simple numbers, use Avg instead. If you need the async version of this function, use the asyncaggregate.AvgComplexType instead.

func Count

func Count[In any](prevStage stages.Stage[In], confs ...configs.StageConfig) (*int64, error)

Count is a sync aggregation function that counts all the elements from the stage channel. This function returns error if the pipeline is interrupted before the stage finishes. The error is obtained internally by calling the `context.Err()` function.

This is a final stage function, which means that it leads to the end of the pipeline. If you need to set up the pipeline, use functions from the [pipeline] package. If you need to make more transformations, use functions from the [transform] package instead.

If you need the async version of this function, use the asyncaggregate.Count instead.

func Distinct

func Distinct[In comparable](prevStage stages.Stage[In], confs ...configs.StageConfig) (*[]In, error)

Distinct is a sync aggregation function that returns all the distinct elements from the stage channel as a slice. This function returns error if the pipeline is interrupted before the stage finishes. The error is obtained internally by calling the `context.Err()` function.

The result is in a random order.

This function is useful when you need to remove all the duplicate elements from the stage channel.

Only the comparable types are supported.

This is a final stage function, which means that it leads to the end of the pipeline. If you need to set up the pipeline, use functions from the [pipeline] package. If you need to make more transformations, use functions from the [transform] package instead.

If you need to count the distinct elements, use DistinctCount instead. If you need the async version of this function, use the asyncaggregate.Distinct instead.

func DistinctCount

func DistinctCount[In comparable](prevStage stages.Stage[In], confs ...configs.StageConfig) (*int64, error)

DistinctCount is a sync aggregation function that counts all the distinct elements from the stage channel. This function returns error if the pipeline is interrupted before the stage finishes. The error is obtained internally by calling the `context.Err()` function.

This function is useful when you need to count all the distinct elements from the stage channel.

Only the comparable types are supported.

This is a final stage function, which means that it leads to the end of the pipeline. If you need to set up the pipeline, use functions from the [pipeline] package. If you need to make more transformations, use functions from the [transform] package instead.

If you need to get the distinct elements, use Distinct instead. If you need the async version of this function, use the asyncaggregate.DistinctCount instead.

func ForEach

func ForEach[In any](prevStage stages.Stage[In], forEachFunc functions.ForEachFunc[In], confs ...configs.StageConfig) error

ForEach is a sync aggregation function that iterates over all the elements from the stage channel and calls the given function for each of them. This function returns error if the pipeline is interrupted before the stage finishes. The error is obtained internally by calling the `context.Err()` function.

This function is useful when you need to iterate over all the elements from the stage channel, but you don't need to return any value.

This is a final stage function, which means that it leads to the end of the pipeline. If you need to set up the pipeline, use functions from the [pipeline] package. If you need to make more transformations, use functions from the [transform] package instead.

If you need the async version of this function, use the asyncaggregate.ForEach instead.

func GroupBy

func GroupBy[In any, K comparable](prevStage stages.Stage[In], groupByFunc functions.MapFunc[In, K], confs ...configs.StageConfig) (*map[K][]In, error)

GroupBy is a sync aggregation function that groups all the elements from the stage channel by the given function and returns them as a map of a key to a slice of values. This function returns error if the pipeline is interrupted before the stage finishes. The error is obtained internally by calling the `context.Err()` function.

Only the comparable types are supported.

This is a final stage function, which means that it leads to the end of the pipeline. If you need to set up the pipeline, use functions from the [pipeline] package. If you need to make more transformations, use functions from the [transform] package instead.

If you need the async version of this function, use the asyncaggregate.GroupBy instead.

func Max

func Max[In types.Number](prevStage stages.Stage[In], confs ...configs.StageConfig) (*In, error)

Max is a sync aggregation function that returns the maximum of all the elements from the stage channel. This function returns error if the pipeline is interrupted before the stage finishes. The error is obtained internally by calling the `context.Err()` function.

This is a final stage function, which means that it leads to the end of the pipeline. If you need to set up the pipeline, use functions from the [pipeline] package. If you need to make more transformations, use functions from the [transform] package instead.

It is not possible to use this function with complex numbers, as Go offers no way to compare them. If you need the async version of this function, use the asyncaggregate.Max instead.

func Min

func Min[In types.Number](prevStage stages.Stage[In], confs ...configs.StageConfig) (*In, error)

Min is a sync aggregation function that returns the minimum of all the elements from the stage channel. This function returns error if the pipeline is interrupted before the stage finishes. The error is obtained internally by calling the `context.Err()` function.

This is a final stage function, which means that it leads to the end of the pipeline. If you need to set up the pipeline, use functions from the [pipeline] package. If you need to make more transformations, use functions from the [transform] package instead.

It is not possible to use this function with complex numbers, as Go offers no way to compare them. If you need the async version of this function, use the asyncaggregate.Min instead.

func Reduce

func Reduce[In any](prevStage stages.Stage[In], reduceFunc functions.ReduceFunc[In], confs ...configs.StageConfig) (*In, error)

Reduce is a sync aggregation function that reduces all the elements from the stage channel to a single value using the given function. This function returns error if the pipeline is interrupted before the stage finishes. The error is obtained internally by calling the `context.Err()` function.

This is a final stage function, which means that it leads to the end of the pipeline. If you need to set up the pipeline, use functions from the [pipeline] package. If you need to make more transformations, use functions from the [transform] package instead.

If you need to reduce the elements to a slice, use AsSlice instead. If you need to reduce the elements to a sorted slice, use Sort or SortDesc instead. If you need to reduce the elements to a map, use AsMap instead. If you need to reduce the elements to a multimap, use AsMultiMap instead. If you need to reduce the elements to a single value, use Sum, Avg, Max, Min or Count instead. If you need the async version of this function, use the asyncaggregate.Reduce instead.

func Sort

func Sort[In cmp.Ordered](prevStage stages.Stage[In], confs ...configs.StageConfig) (*[]In, error)

Sort is a sync aggregation function that sorts all the elements from the stage channel in the ascending order and returns them as a slice. This function returns error if the pipeline is interrupted before the stage finishes. The error is obtained internally by calling the `context.Err()` function.

Only the ordered types are supported.

This is a final stage function, which means that it leads to the end of the pipeline. If you need to set up the pipeline, use functions from the [pipeline] package. If you need to make more transformations, use functions from the [transform] package instead.

It is not possible to use this function with complex numbers, as Go offers no way to compare them. If you need to sort numbers in the descending order, use SortDesc instead. If you need the async version of this function, use the asyncaggregate.Sort instead.

func SortDesc

func SortDesc[In cmp.Ordered](prevStage stages.Stage[In], confs ...configs.StageConfig) (*[]In, error)

SortDesc is a sync aggregation function that sorts all the elements from the stage channel in the descending order and returns them as a slice. This function returns error if the pipeline is interrupted before the stage finishes. The error is obtained internally by calling the `context.Err()` function.

Only the ordered types are supported.

This is a final stage function, which means that it leads to the end of the pipeline. If you need to set up the pipeline, use functions from the [pipeline] package. If you need to make more transformations, use functions from the [transform] package instead.

It is not possible to use this function with complex numbers, as Go offers no way to compare them. If you need to sort numbers in the ascending order, use Sort instead. If you need the async version of this function, use the asyncaggregate.SortDesc instead.

func Sum

func Sum[In types.Number](prevStage stages.Stage[In], confs ...configs.StageConfig) (*In, error)

Sum is a sync aggregation function that sums all the elements from the stage channel. This function returns error if the pipeline is interrupted before the stage finishes. The error is obtained internally by calling the `context.Err()` function.

This is a final stage function, which means that it leads to the end of the pipeline. If you need to set up the pipeline, use functions from the [pipeline] package. If you need to make more transformations, use functions from the [transform] package instead.

If you need to sum complex numbers, use SumComplexType instead. If you need to sum numbers of a custom type, use Reduce instead. If you need the async version of this function, use the asyncaggregate.Sum instead.

func SumComplexType

func SumComplexType[In types.ComplexNumber](prevStage stages.Stage[In], confs ...configs.StageConfig) (*In, error)

SumComplexType is a sync aggregation function that sums all the elements from the stage channel. This function returns error if the pipeline is interrupted before the stage finishes. The error is obtained internally by calling the `context.Err()` function.

This is a final stage function, which means that it leads to the end of the pipeline. If you need to set up the pipeline, use functions from the [pipeline] package. If you need to make more transformations, use functions from the [transform] package instead.

If you need to sum simple numbers, use Sum instead. If you need to sum numbers of a custom type, use Reduce instead. If you need the async version of this function, use the asyncaggregate.SumComplexType instead.

Types

This section is empty.

Jump to

Keyboard shortcuts

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