Reading a layer's channels from its packed columns through the frame's scales (spec/04
§1.3, §1.12), copied from visualize's Visualize.Chart.Mark.Channels and
Visualize.Chart.Mark.Pixels.
A channel's value in a checked layer is {:field, name}, a number, or {:scale, :min | :max | :boundary}. Every row is read at once, from the packed column, never row by
row through Macaw.Data.Table.get/2:
- a field reads its column and maps it through the channel's scale when the frame
declares that scale, else reads it as pixels. A
:numberfield, and a:timefield through a time scale, is read where it lies (Macaw.Frame.Columns.numbers/2) and mapped byMacaw.Draw.Scale.apply_column/2to a pixel binary in one pass, no value decoded (macaw_frame#62); a:categoryfield held as a dictionary, through a band or a color scale, places or colors each dictionary entry once and writes its codes in one pass, no string decoded a row (macaw_frame#82); any other field is decoded once (Macaw.Frame.Columns.read/3); - a number is the constant, mapped likewise, for every row;
{:scale, :min}and{:scale, :max}are the low and the high end of the domain of the channel's scale (by value where numeric, the first and last member where discrete), mapped like a reading; a channel whose scale is not declared places nothing;{:scale, :boundary}is the delivery'sserved.complete_untilthrough the scale: a layer reading it draws one element from its first row (boundary?/1);- through a
bandscale a:positionchannel is the band's center and an:edgechannel its start (x0,y0) or end (x1,y1); anoffsetplaces the inner band inside it (x_offset,y_offset); - a reading the scale cannot place is unplaced: the column holds
nilthere, the maskplaced/1reads, never a raise.
pixels/3 answers %Macaw.Frame.Layer.Read{}: count rows, columns each channel's
pixel column, raw the raw readings of the channels read unmapped (series, path, a
text's value), in index order. Nothing is transposed into a map per row (§1.12): a kind
zips the columns it draws (zip/3), and reads a row by index only for an edge that names
it. The read is one pass per channel; the Frame caches it per delivery (§1.3).
Summary
Types
A pixel binary: float64 little-endian, a slot a row, NaN where unplaced.
Functions
A channel's pixel column of a read as a pixel binary (spec/04 §1.3): float64
little-endian, a slot a row, NaN where unplaced, as Macaw.Draw.Scale.apply_column/2
answers it; nil for a channel the read does not place by number (a color, a raw
reading). A channel placed from a packed column holds its binary as mapped, one pass and
no list; any other numeric column is written into one.
A source's table read through a surface's binding of a layer's roles (§1.2): each role's
column is the source field bindings binds it to (%{role => field}), every other
column as it is, so a design written against "t" and "cpu" reads a source whose
fields are "timestamp" and "load" (Macaw.Frame.Columns.bound/2).
Whether a layer reads its slot's boundary: one element, not one per row (§1.3).
One channel's pixel column over table (§1.3): its reading mapped through scale (a
realized Macaw.Draw.Scale, or nil for pixels), nil where unplaced. channel is the
declaration, for the band rule; offset an inner band {scale, column} or nil.
A field's raw values over a table, by either spelling of its name (Macaw.Data.Table .column/2), nil in every row where the table has no such column.
A pixel binary read out as a list: each slot's float, nil where it holds NaN.
A channel's pixel column of a read as a list, nil in every row where the layer gives
none or the reading is unplaced; a pixel binary (binary/2) read out a float a row.
Whether the read holds a channel.
The table's own name of a field, by either spelling ("v" finds :v and the other
way round); nil where the table has no such column.
Every channel of a checked layer read over table in model (§1.3): the pixel columns
of the channels its kind maps, the raw columns of those read unmapped. A layer reading
{:scale, :boundary} reads its table's first row only. A layer the realization placed
over this same table (Macaw.Frame.Placements, spec/11 §5.5) answers that placement,
read rather than placed again.
The unplaced mask of a column: true where a reading is placed (§1.3).
The rows of a table at indices, read by index in one gather: the edge that names a row.
Slot i of a pixel binary: its float, nil where unplaced or past the end; read in
place, at no cost of the rows.
The rows' columns of names zipped, one tuple per row {index, value…} in index order,
kept where every name of required is placed (§1.12): the one pass a kind draws its
elements in, never a map per row.
Types
Functions
A channel's pixel column of a read as a pixel binary (spec/04 §1.3): float64
little-endian, a slot a row, NaN where unplaced, as Macaw.Draw.Scale.apply_column/2
answers it; nil for a channel the read does not place by number (a color, a raw
reading). A channel placed from a packed column holds its binary as mapped, one pass and
no list; any other numeric column is written into one.
iex> read = %Macaw.Frame.Layer.Read{count: 2, columns: %{"x" => [1.0, nil]}}
iex> pixels = Macaw.Frame.Layer.Read.binary(read, "x")
iex> Macaw.Frame.Layer.Read.floats(pixels)
[1.0, nil]
@spec bound(Macaw.Data.Table.t(), map()) :: Macaw.Data.Table.t()
A source's table read through a surface's binding of a layer's roles (§1.2): each role's
column is the source field bindings binds it to (%{role => field}), every other
column as it is, so a design written against "t" and "cpu" reads a source whose
fields are "timestamp" and "load" (Macaw.Frame.Columns.bound/2).
Whether a layer reads its slot's boundary: one element, not one per row (§1.3).
@spec column( Macaw.Frame.Layer.Channel.t(), term(), Macaw.Data.Table.t(), struct() | nil, keyword() ) :: column()
One channel's pixel column over table (§1.3): its reading mapped through scale (a
realized Macaw.Draw.Scale, or nil for pixels), nil where unplaced. channel is the
declaration, for the band rule; offset an inner band {scale, column} or nil.
@spec field(Macaw.Data.Table.t(), term()) :: list()
A field's raw values over a table, by either spelling of its name (Macaw.Data.Table .column/2), nil in every row where the table has no such column.
A pixel binary read out as a list: each slot's float, nil where it holds NaN.
iex> Macaw.Frame.Layer.Read.floats(<<1.5::float-little-64, 0, 0, 0, 0, 0, 0, 0xF8, 0x7F>>)
[1.5, nil]
A channel's pixel column of a read as a list, nil in every row where the layer gives
none or the reading is unplaced; a pixel binary (binary/2) read out a float a row.
Whether the read holds a channel.
@spec name(Macaw.Data.Table.t(), term()) :: Macaw.Data.Table.name() | nil
The table's own name of a field, by either spelling ("v" finds :v and the other
way round); nil where the table has no such column.
@spec pixels(map(), Macaw.Data.Table.t(), Macaw.Frame.Coordinates.Model.t()) :: t()
Every channel of a checked layer read over table in model (§1.3): the pixel columns
of the channels its kind maps, the raw columns of those read unmapped. A layer reading
{:scale, :boundary} reads its table's first row only. A layer the realization placed
over this same table (Macaw.Frame.Placements, spec/11 §5.5) answers that placement,
read rather than placed again.
The unplaced mask of a column: true where a reading is placed (§1.3).
iex> Macaw.Frame.Layer.Read.placed([1.0, nil, 3.0])
[true, false, true]
@spec rows_at(Macaw.Data.Table.t(), [non_neg_integer()]) :: [map()]
The rows of a table at indices, read by index in one gather: the edge that names a row.
@spec slot(binary(), non_neg_integer()) :: float() | nil
Slot i of a pixel binary: its float, nil where unplaced or past the end; read in
place, at no cost of the rows.
iex> Macaw.Frame.Layer.Read.slot(<<1.5::float-little-64, 2.5::float-little-64>>, 1)
2.5
The rows' columns of names zipped, one tuple per row {index, value…} in index order,
kept where every name of required is placed (§1.12): the one pass a kind draws its
elements in, never a map per row.
iex> read = %Macaw.Frame.Layer.Read{count: 3, columns: %{"x" => [0, 1, nil], "y" => [5, nil, 7]}}
iex> Macaw.Frame.Layer.Read.zip(read, ["x", "y"], ["x"])
[{0, 0, 5}, {1, 1, nil}]