vars

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 6 Imported by: 0

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

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 New

func New(calc tmpl.CalcMode) *Accumulator

New builds an empty accumulator.

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) Reset

func (acc *Accumulator) Reset()

Reset empties the accumulator.

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".

type State

type State struct {
	// contains filtered or unexported fields
}

State is a snapshot, taken so that a detail band which turns out not to fit can have its fold rolled back and reapplied after the eject.

Jump to

Keyboard shortcuts

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