# `Macaw.Data.Aggregate`
[🔗](https://github.com/dcoai/macaw_data/blob/v0.5.3/lib/macaw/data/aggregate.ex#L1)

The aggregate behavior (spec/04 §1.2): a statistic, one column's readings reduced to one
value (visualize#909).

`reduce/2` is given the readings with every `nil` dropped, since a gap is absence, never
zero (spec/01 §1.1). An aggregate may also give the streaming form, `init/1`, `step/3`
and `finish/2` together, over the same readings in the same order:

    finish(Enum.reduce(values, init(options), &step(&2, &1, options)), options)
    == reduce(values, options)

Its options are checked as a transform's are (`Macaw.Data.Operations.Option`), and may
not be a key of a step that names it (`Macaw.Data.Operations.step_keys/0`): the registry
refuses one that is.

# `options`

```elixir
@type options() :: %{required(String.t()) =&gt; term()}
```

Checked options: each declared option by its string, its default filled in.

# `finish`
*optional* 

```elixir
@callback finish(term(), options()) :: term()
```

The streaming form's value of its state.

# `init`
*optional* 

```elixir
@callback init(options()) :: term()
```

The streaming form's first state.

# `keeps_unit?`

```elixir
@callback keeps_unit?() :: boolean()
```

Whether the input's unit and quantity carry to the output.

# `name`

```elixir
@callback name() :: String.t()
```

The name a node's `fn` or a stored function names, unique in a registry.

# `options`

```elixir
@callback options() :: [{String.t(), Macaw.Data.Operations.Option.t()}]
```

The keys the aggregate reads.

# `output`

```elixir
@callback output(Macaw.Data.Table.type(), options()) :: Macaw.Data.Table.type()
```

The output's table type for an input column of `type`.

# `reduce`

```elixir
@callback reduce([term()], options()) :: term()
```

The value of the readings, `nil`s already dropped.

# `step`
*optional* 

```elixir
@callback step(term(), term(), options()) :: term()
```

The streaming form's state after one more reading.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
