tdfs4ds.process_store.followup_grid¶
tdfs4ds.process_store.followup_grid
¶
The skip decision of a whole roll_out, read before its first step (0.3.8.1).
roll_out used to ask, at every (process, date), whether the pair is already final: at least one
statement per pair, so a domain already COMPLETED at every date still cost round trips per step (about
3 s per skipped step from a remote client). The grid below answers the same question for every pair of
the call with a handful of statements. It only ever says "done" (the pair is then skipped exactly as the
per-step decision would skip it); every other pair goes through the historical per-step statements,
unchanged, and so does every pair when the grid cannot be trusted.
A pair counts as done under the rules of nothing_to_compute / final_runs_at (same counts, same
segment matching, same upstream rule):
- a
COMPLETEDrow at that valid time (with a FilterManager: every segment holds one); - or, with no
COMPLETEDrow, aCOMPLETED,0 rowsrow that no upstream process followed (with a FilterManager: every segment without aCOMPLETEDrow holds such an empty row).
The second kind depends on what upstream processes write at the SAME valid time, which a step of this very
call can change: those pairs are flagged volatile and trusted only while no step of that valid time has
computed anything (:func:mark_date_dirty). A step of this call only ever adds COMPLETED rows, so the
first kind never needs to be asked again. A row written or deleted by another session while the call runs
is a race the per-step statements had as well (they read at the moment of the step; the grid at the
start), and a decision "todo" is never taken from the grid.
Layers: the SQL builders and the decisions are pure; :func:build_call_grid is the only reader and never
raises.
logger_safe
¶
Wrapper around the global logger that only emits logs when
tdfs4ds.DISPLAY_LOGS is True. level is a string like "info", "error", etc.
sql_literal
¶
Escape value for use inside a single-quoted SQL string literal.
For the DBC probes and catalog predicates that compare a name as data
(WHERE DatabaseName = '…'). The caller supplies the surrounding quotes.
_followup_source
¶
The run history of every attached store that offers one, as a derived
table (FS_V_FOLLOW_UP of each, tagged FEATURE_STORE), or None with a
single store -- then the primary's table is read exactly as before.
Run rows are keyed by PROCESS_ID, a UUID, so a row always belongs to the process of the store it came from.
_resolved_upstream
¶
Sorted upstream process ids (the process itself left out), or None when unknown.
final_empty_sql
¶
final_empty_sql(process_id: str, valid_time, upstream, filtermanager: Optional[object] = None) -> str
SELECT COUNT(*) of the COMPLETED,0 rows rows of process_id at valid_time (current segment
with filtermanager) that no run of an upstream process followed: no upstream row COMPLETED at the
same valid time started after the empty row ended. With no upstream, every empty row counts. Pure.
missing_final_segments_sql
¶
:func:missing_segments_sql for a segment counting as done when it has a COMPLETED row OR a
COMPLETED,0 rows row that no run of an upstream process followed (see :func:final_empty_sql).
_date_case
¶
CASE WHEN col = 'vt' THEN k ...: the position of the valid time in valid_times, compared with
the very = the per-step statements use (the literal converted to the column's type).
grid_plain_sql
¶
One statement for every process without a FilterManager and every valid time: (PROCESS_ID, k,
n COMPLETED, n COMPLETED,0 rows) where k is the position of the valid time. The rows
completed_state_sql counts, for all the pairs at once. Pure.
grid_segments_sql
¶
followup_grid_sql for every valid time at once: (filter_id, k, n COMPLETED, n COMPLETED,0
rows), only for the segments that have such a row (the caller counts the others as zero). Pure.
decide_plain
¶
The skip decision of a process with no FilterManager from its counts (n_completed, n_empty), as
final_runs_at takes it. ("done", volatile), ("todo", None), or ("ask", None): done
when the empty run is still the last word, which needs the upstream statement. upstream: sorted
upstream process ids, or None when unknown (then an empty run is recomputed). Pure.
decide_segments
¶
The skip decision of a process with a FilterManager from {filter_id: (n_completed, n_empty)} over
ALL its segments, as nothing_to_compute takes it. Same return as :func:decide_plain. Pure.
_leg
¶
sql (a SELECT COUNT(*) FROM ...) with the key of the pair in front of its count, to be
stacked with UNION ALL (a table-less SELECT is not allowed in a union).
build_call_grid
¶
The pairs (process_id, valid time) of a roll_out that are already final, from a few statements.
entries: [(process_id, filtermanager or None)]; valid_times: the valid-time text of each
step (what run sees as FEATURE_STORE_TIME). Returns {(process_id, valid_time text):
volatile} holding only the pairs the per-step decision would skip, or None when the grid cannot
be trusted (read-only stores attached, any read failing): the caller then keeps the per-step
statements. Never raises.
install_call_grid
¶
Keep grid (from :func:build_call_grid) for the running call. No call memo, or None: nothing.
grid_says_done
¶
True when the call's grid already knows (process_id, valid_time) is final, and nothing since
could have changed it. Never reads the database.
mark_date_dirty
¶
A step of this valid time computed something: decisions resting on what upstream processes wrote at the same valid time are asked again, with the per-step statements.
date_is_done
¶
True when :func:grid_says_done holds for every process of process_ids at valid_time.