Macaw.Data.Source.Planner (macaw_data v0.21.1)
View SourceThe reads a source manager makes, from a demand change and what it holds (spec/01 §6.4.2): as few, well-sized reads as the adapter allows.
plan(needed, held, opts) answers the slot ranges to read (Macaw.Data.Source.Ranges),
sorted and disjoint: the slots needed lacks from held (held, or asked and not yet
answered), with
- gaps at most the merge distance apart read as one, the slots between them too,
since one call costs more than their rows (
Cost.merge_distance/2ofcost:atrows_per_slot:rows a slot); - a bounded read longer than
cap:slots split into pieces of at mostcap:, in order, so its first part is not held back; ahead:slots read ahead past the last read, up to the first slot held, on a moving leading edge;- one whole read,
{nil, nil}, for an adapter that doesn't honor windows (windows: false).
No other slot is read. Options it can't use are faults by path, every one at once.
iex> alias Macaw.Data.Source.Planner
iex> alias Macaw.Data.Source.Planner.Cost
iex> {:ok, cost} = Cost.new(call: 2.0, row: 1.0)
iex> Planner.plan([{0, 20}], [{5, 7}, {12, 18}], cost: cost, rows_per_slot: 1)
{:ok, [{0, 12}, {18, 20}]}
Summary
Functions
The reads to make for needed given held: {:ok, reads}, or the options' faults.
Options: cost: a Cost (Cost.new/0's by default), rows_per_slot: the rows a
slot holds (Macaw.Data.Table.chunk_rows/0), cap: the most slots a bounded read takes (64),
ahead: the slots to read ahead (0) and windows: whether the adapter honors windows
(true).
Types
@type range() :: Macaw.Data.Source.Ranges.range()
Functions
The reads to make for needed given held: {:ok, reads}, or the options' faults.
Options: cost: a Cost (Cost.new/0's by default), rows_per_slot: the rows a
slot holds (Macaw.Data.Table.chunk_rows/0), cap: the most slots a bounded read takes (64),
ahead: the slots to read ahead (0) and windows: whether the adapter honors windows
(true).