Skip to main content

Module on_demand_jit

Module on_demand_jit 

Source
Expand description

Query-driven materialization of on-demand SQL views Query-driven materialization of on-demand SQL views (DDL views with no update_group).

A query over query_range fills and refreshes the partitions covering that range, so nothing is materialized for ranges nobody reads. The range is cut along the bucket ladder (see partition_ladder), each bucket’s freshness is probed with the view’s own authored count_src_query, and the stale ones are rewritten with its extract_query.

No partition is built from more source data than the view’s byte cap (max_jit_src_data), except at the finest rung: a stale unit whose source bytes exceed the cap is rewritten as finer ladder buckets, committed together with the retire of the unit’s rows, and promotion never merges rows into a partition that would exceed the cap in bytes or in source bytes.

A bucket grows into a [Unit] that contains every partition row it intersects (an earlier query at a coarser rung, a promotion, or rows left by the daemon before a view was converted), so a write’s containment retire always replaces everything it overlaps and the verdict of a unit never depends on another unit.

Structs§

Unit
A planned bucket, grown until it contains every partition row it intersects, and coalesced with the units it came to overlap.

Enums§

StaleUnitPlan
What to do with a unit judged stale.
UnitVerdict
Whether a unit’s rows already hold what its probe counted.

Functions§

judge_unit
Covered when the unit has rows, every row was written with the view’s current schema, and the rows’ summed source_data_hash equals the count the probe returned. This is the maintenance daemon’s freshness rule (equality, summed), so a definition gets the same verdicts under either writer.
plan_stale_unit
A unit within the byte cap is written whole. Otherwise it is rebuilt as the leaves plan_by_source_bytes picks, which replace the unit’s rows in one commit, however coarse those rows were. A unit that is itself one finest-rung bucket has nothing to split, so it is written whole whatever its size.
plan_units
Grows each planned bucket until it contains every row that intersects it, then coalesces the units that came to overlap. planned is ascending and non-overlapping. Rows are half-open against the unit (Aligned): SQL partitions touch at bucket edges, and a neighbor that merely touches is not absorbed.
promotion_targets
Picks the units to promote: covered, closed, exactly one planned bucket at the query’s rung (not grown). split_promotion then decides what to merge within each, under the byte cap. Pure, like promotion_candidates.
source_bytes
Bytes of source data an extract over range reads: the file_size of the sources’ partitions, each prorated by the share of its insert range that lies in range. A zero-width partition counts whole when its insert time is in [begin, end). Prorating assumes data is spread evenly in insert time, which is good enough for a cap: extracts filter their sources by insert time. Partitions of other views, or of a source under another file schema, count for nothing.
split_promotion
Picks what to merge within one covered, closed bucket: the whole of range when rows merge within the byte cap and a rebuild of range would read at most cap source bytes. Otherwise, when the rows would merge but a cap is exceeded, each child bucket of the next finer rung gets the same treatment over the rows lying inside it. A child that a row straddles is skipped, since the row cannot be split. With fewer than two rows there is nothing to merge.
update_on_demand_view
Brings an on-demand view up to date for query_range: sizes buckets from the range, probes each one, rewrites the stale ones, then promotes closed history to the range’s rung.