TinyBase logoTinyBase

AggregateAdd

The AggregateAdd type describes a function that can be used to optimize a custom Aggregate by providing a shortcut for when a single value is added to the input values.

(
  current: Cell,
  add: Cell,
  length: number,
): ResultCellOrUndefined
TypeDescription
currentCell

The current value of the aggregation.

addCell

The Cell value being added to the aggregation.

lengthnumber

The length of the array of Cell values in the aggregation.

returnsResultCellOrUndefined

The new value of the aggregation.

Some aggregation functions do not need to recalculate the aggregation of the whole set when one value changes. For example, when adding a new number to a series, the new sum of the series is the new value added to the previous sum.

If it is not possible to shortcut the aggregation based on just one value being added, return undefined and the aggregation will be completely recalculated.

Where possible, if you are providing a custom Aggregate, seek an implementation of an AggregateAdd function that can reduce the complexity cost of growing the input data set.

Since

v2.0.0