Visualize.Data.Delivery (Visualize v0.7.0)

Copy Markdown View Source

One answer of a feed: its rows, and the facts of this answer (spec/08 §10.4, D-136).

rows is any source Visualize.Data.Table.rows/1 reads — a row list, a column map, a tensor, a Table.Reader struct. Beside it, a handful of terms per delivery, never per row: the window actually served, the resolution of the rows, whether the feed capped the answer short of the window asked for, who reduced the rows to a budget (reduced_by), and the schema version the rows were produced under — never the schema itself, which Visualize.Data.Schema.Cache holds by version.

A delivery is one more source shape: Visualize.Data.Table.rows/1 reads it as the rows of the source it carries, and Visualize.Chart.apply/2 and a compiled chart take one wherever they take a source.

Examples

iex> delivery = Visualize.Data.Delivery.new(%{t: [1, 2], v: [3, 4]}, window: [0, 10], schema: "ab12")
iex> Visualize.Data.Table.rows(delivery)
[%{t: 1, v: 3}, %{t: 2, v: 4}]
iex> {delivery.capped, delivery.reduced_by}
{false, nil}

Summary

Functions

A delivery of the rows with the given facts (spec/08 §10.4): window, resolution, capped, reduced_by and schema. Raises ArgumentError for a key that is not one of them or a value the field does not take.

The source a delivery carries; any other source as it is.

Types

t()

@type t() :: %Visualize.Data.Delivery{
  capped: boolean(),
  reduced_by: :feed | :visualize | nil,
  resolution: term(),
  rows: Visualize.Data.Table.source(),
  schema: String.t() | nil,
  window: [term()] | nil
}

Functions

new(rows, facts \\ [])

@spec new(Visualize.Data.Table.source(), keyword()) :: t()

A delivery of the rows with the given facts (spec/08 §10.4): window, resolution, capped, reduced_by and schema. Raises ArgumentError for a key that is not one of them or a value the field does not take.

source(source)

The source a delivery carries; any other source as it is.

iex> Visualize.Data.Delivery.source(Visualize.Data.Delivery.new([%{v: 1}]))
[%{v: 1}]
iex> Visualize.Data.Delivery.source([%{v: 1}])
[%{v: 1}]