Macaw.Data.Manager.Finished (macaw_data v0.21.1)
View SourceIdentical asks finished once (spec/01 §6.4.6, dco-tek/macaw/macaw#108 "Reader workers"):
a window a reader asks of a manager's table, finished for its request, is computed by
the first process to ask it and read by every other asking it meanwhile or after, in
the manager's table under {:finished, ask, inputs, served}:
ask, the request as finishing reads it (its window, box, region, latest, order, budget and reducer; never itsnow, viewer or subscription, which finishing doesn't read, and whose params, as-of and viewer the manager's key already names);inputs, the{id, seq}of every published chunk the window reads, each naming one content for the table's life, so an entry is valid exactly while its inputs are published;served, the index's served facts thatMacaw.Data.Source.Manager.read/3states and the chunks don't carry (spec/01 §6.4.3), which an answer can move without moving a chunk's contents: the slot ranges a capped answer, or one the source reduced itself, last held, and the holding's stale, note, resolution andcomplete_until. Never its position, which every push moves: the finished window states the position it was first finished at.
The worker is the first asker's own process, most often a short-lived one (a
turn of a host's, a proof): it claims the ask with :ets.insert_new/2,
finishes it, puts the result in its entry and answers each process that asked
meanwhile. Another asker finds the entry finished and reads it, or finds it claimed and
waits for the claimer's answer, or the claimer's end (it then takes the ask over). A
one-off ask is finished in its asker's own process, as before, at the cost of one
insert_new. An entry holds no chunk past its inputs' publication: the manager deletes
the entries whose inputs a publication superseded (purge/2), and a claimer finishing
after that deletes its own (run/3).
Summary
Functions
How many asks table's readers finished, and the reductions finishing took (a finish
tried again on a fresh index among them):
%{count: n, reductions: r}, each since the table was made.
table counting its finishes: the manager's, when it makes its table.
The key of request's window over index, with the index's served facts but its
position.
The result of key in table, computed once: read from its entry when finished,
waited for when another process is finishing it, else finished here by compute, which
answers {:ok, delivery}, {:error, faults} (both kept) or {:error, {:missing, id, seq}} (a chunk superseded under the read, not kept: its asker reads the fresh index).
The entries of table whose inputs include a chunk superseded names, deleted: the
manager's, after a publication.
Types
@type key() :: {:finished, Macaw.Data.Source.Request.t(), [{term(), non_neg_integer()}], map()}
An entry's key: {:finished, ask, inputs, served}.
Functions
@spec counted(:ets.tid()) :: %{ count: non_neg_integer(), reductions: non_neg_integer() }
How many asks table's readers finished, and the reductions finishing took (a finish
tried again on a fresh index among them):
%{count: n, reductions: r}, each since the table was made.
@spec counting(:ets.tid()) :: :ok
table counting its finishes: the manager's, when it makes its table.
@spec key(Macaw.Data.Source.Manager.Index.t(), Macaw.Data.Source.Request.t()) :: key()
The key of request's window over index, with the index's served facts but its
position.
The result of key in table, computed once: read from its entry when finished,
waited for when another process is finishing it, else finished here by compute, which
answers {:ok, delivery}, {:error, faults} (both kept) or {:error, {:missing, id, seq}} (a chunk superseded under the read, not kept: its asker reads the fresh index).
@spec purge(:ets.tid(), [{term(), non_neg_integer()}]) :: :ok
The entries of table whose inputs include a chunk superseded names, deleted: the
manager's, after a publication.