A delivery read into its slot's table (spec/05 §4), copied from visualize's
Visualize.Chart.Compiled.Sources (the one function every place a delivery's data
enters calls, a source its slot cannot read a fault, never a raise) and
Visualize.Data.Same (two terms the same data when their tables are equal by content,
never by chunking). Its five rescue sites are not carried over: every answer is a
value.
- A delivery holding a
Macaw.Data.Tableis held as that very table (§4.2): no copy, no repack, its chunks' identities kept, so the per-chunk cache reuses every unchanged chunk's part. - Any other rows are packed once, by
Macaw.Data.Delivery.table/2with the slot's declared types; tuple rows are named by the slot's bound fields first (its declared fields in order, each read through the cell's binding). Rows that do not pack are{:rows, reason}, which the value holds at["sources", slot]. - The roles are read by their bound fields when the layers draw, through the one
column accessor
Macaw.Frame.Columns.bound/2, never by decoding the table here. - What a delivery says beside its rows (§4.3,
drawn/1):served.window,served.resolution,served.reduced_withandserved.complete_untilchange the picture (a continuous layer handed rows reduced by M4 at its width draws them without reducing again,Macaw.Frame.Layer.Device.reduced?/2);served.stale,cappedandreduced_byare the host's drawn state and change no pixel, so two deliveries differing only in those draw the same.
Summary
Functions
The served facts that change the picture (§4.3): window, resolution,
reduced_with and complete_until; stale, capped and reduced_by are left out.
Whether two terms hold the same data (visualize's Visualize.Data.Same.same?/2): every
Macaw.Data.Table in them compared by Macaw.Data.Table.equal?/2, by its contents and
never its chunking, everything else by ==.
The schema a slot of static rows is read under (spec/02 §2.3): each field at its
declared type (:text where none is declared), the fields its requires names with
:identity the identity; nil for a slot of no static rows.
A slot's static rows as the delivery a source would make of them (spec/02 §2.3, spec/13
§7.3): {:ok, delivery} holding a Macaw.Data.Table packed column by column from
the rows, one column per field of the slot in its order, each of the slot's declared
type (a field with none packs as :term) and read at the edge as from/2 reads it (a
Date in a :time column as a DateTime); :none for a slot of no static rows; or
{:error, {:rows, faults}} for rows that do not pack. No row is built: each column is
read off the rows once.
A delivery's rows as its slot's table (§4.2): {:ok, table}, the delivery's own table
when it holds one, else its rows packed with the slot's declared types and, for rows
without names, the slot's fields named through bindings (%{role => field}); or
{:error, {:rows, reason}} for rows that do not pack.
Functions
The served facts that change the picture (§4.3): window, resolution,
reduced_with and complete_until; stale, capped and reduced_by are left out.
iex> d = Macaw.Data.Delivery.new!([%{"v" => 1}], served: [stale: true, window: [0, 9]])
iex> Macaw.Frame.Read.drawn(d)
%{complete_until: nil, reduced_with: nil, resolution: nil, window: [0, 9]}
Whether two terms hold the same data (visualize's Visualize.Data.Same.same?/2): every
Macaw.Data.Table in them compared by Macaw.Data.Table.equal?/2, by its contents and
never its chunking, everything else by ==.
iex> Macaw.Frame.Read.same?(%{a: [1, 2]}, %{a: [1, 2]})
true
iex> Macaw.Frame.Read.same?([1], [2])
false
@spec schema(term()) :: Macaw.Data.Schema.t() | nil
The schema a slot of static rows is read under (spec/02 §2.3): each field at its
declared type (:text where none is declared), the fields its requires names with
:identity the identity; nil for a slot of no static rows.
iex> schema = Macaw.Frame.Read.schema(%{fields: ["id"], requires: %{"id" => [:identity]}, rows: []})
iex> Macaw.Data.Schema.identity(schema)
["id"]
@spec static(term()) :: {:ok, Macaw.Data.Delivery.t()} | :none | {:error, {:rows, term()}}
A slot's static rows as the delivery a source would make of them (spec/02 §2.3, spec/13
§7.3): {:ok, delivery} holding a Macaw.Data.Table packed column by column from
the rows, one column per field of the slot in its order, each of the slot's declared
type (a field with none packs as :term) and read at the edge as from/2 reads it (a
Date in a :time column as a DateTime); :none for a slot of no static rows; or
{:error, {:rows, faults}} for rows that do not pack. No row is built: each column is
read off the rows once.
iex> {:ok, d} = Macaw.Frame.Read.static(%{fields: ["id", "n"], types: %{"n" => :number}, rows: [%{"id" => "a", "n" => 1}]})
iex> Macaw.Data.Table.size(d.rows)
1
iex> Macaw.Frame.Read.static(%{fields: ["id"]})
:none
@spec table(term(), term(), term()) :: {:ok, Macaw.Data.Table.t()} | {:error, {:rows, term()}}
A delivery's rows as its slot's table (§4.2): {:ok, table}, the delivery's own table
when it holds one, else its rows packed with the slot's declared types and, for rows
without names, the slot's fields named through bindings (%{role => field}); or
{:error, {:rows, reason}} for rows that do not pack.
iex> {:ok, t} = Macaw.Data.Table.from([%{"v" => 1}])
iex> {:ok, held} = Macaw.Frame.Read.table(Macaw.Data.Delivery.new!(t), %{fields: ["v"]}, %{})
iex> held == t
true
iex> Macaw.Frame.Read.table(%Macaw.Data.Delivery{rows: [1, 2], served: %{}}, %{fields: ["v"]}, %{})
{:error, {:rows, [{[], {:type, :rows}}]}}