Documentation
¶
Overview ¶
Package vars implements variable accumulation: the twelve calc modes.
See doc/expressions.md#variables.
Only list, set and chain retain individual values. Everything else is an incremental accumulator with constant memory, so a report over a hundred thousand rows does not hold a hundred thousand values per variable and does not recompute an aggregate on every read.
Index ¶
- type Accumulator
- func (acc *Accumulator) Check(value starlark.Value) error
- func (acc *Accumulator) Fold(value starlark.Value) error
- func (acc *Accumulator) Reset()
- func (acc *Accumulator) Restore(state State)
- func (a *Accumulator) Retains() bool
- func (acc *Accumulator) Snapshot() State
- func (acc *Accumulator) Value() starlark.Value
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Accumulator ¶
type Accumulator struct {
// contains filtered or unexported fields
}
Accumulator folds values for one variable.
func (*Accumulator) Check ¶
func (acc *Accumulator) Check(value starlark.Value) error
Check reports a value the mode cannot fold, so that the error names the variable rather than surfacing later as a wrong answer.
func (*Accumulator) Fold ¶
func (acc *Accumulator) Fold(value starlark.Value) error
Fold folds one value in.
func (*Accumulator) Restore ¶
func (acc *Accumulator) Restore(state State)
Restore undoes every fold since a snapshot.
func (*Accumulator) Retains ¶
func (a *Accumulator) Retains() bool
Retains reports whether this mode keeps individual values. Only list, set and chain do; everything else is constant memory.
func (*Accumulator) Snapshot ¶
func (acc *Accumulator) Snapshot() State
Snapshot records the accumulator's state.
func (*Accumulator) Value ¶
func (acc *Accumulator) Value() starlark.Value
Value reads the accumulator.
An empty accumulator reads as 0 for count; None for first, last, sum, avg, min, max, std and var; and an empty list, set or chain otherwise. sum of nothing is None rather than 0, so "no rows" stays distinguishable from "rows summing to zero".