Expand description
Management of process-specific partitions built on demand
Just-in-time (JIT) partition generation groups a view’s source blocks (queried from
blocks_view in ORDER BY insert_time, block_id order) into SourceDataBlocksInMemory
partitions no larger than JitPartitionConfig::max_nb_objects.
JitPartitionConfig::block_order (see BlockOrder) picks between two orderings for the
blocks a partition ends up holding: InsertTime (the SQL order, unchanged) for views that
decode blocks independently, and EventTime for views that build cross-block trees or rely on
event-time-sorted rows within a partition file. group_blocks_into_partitions is the single
place both variants are cut, and it upholds one invariant regardless of ordering: every emitted
partition’s [min_insert_time, max_insert_time] range is non-overlapping with, and
non-decreasing relative to, every other emitted partition’s – the precondition the
lakehouse_partitions_no_overlap exclusion constraint enforces at insert time. See
group_blocks_into_partitions’s own docs for how that invariant is upheld under
BlockOrder::EventTime, where the natural size-based cut point is not always safe, and for
the one (production-unreachable) shape it does not cover.
Note that this is an insert-time invariant only. It says nothing about partitions’
event-time ranges, which for the block-derived views are computed from block
begin_ticks/end_ticks. By design both micromegas_tracing and the Unreal producer now stamp
a single shared timestamp per flush, used for both the outgoing block’s close and the
replacement block’s begin, so consecutive blocks touch exactly and adjacent partitions’ event
bounds do not overlap by construction. Data from producer versions predating that fix can still
carry strictly-overlapping block ticks; ThreadSpansView’s recorded max_sort_key_time is what
makes that harmless to the Concatenated scan check (partitioned_execution_plan::partition_bounds
prefers it over the looser max_event_time) rather than requiring every source block to be
re-ingested. See the ordering-invariant notes on View::get_scan_output_ordering and
tasks/completed/thread_spans_segment_boundary_overlap_plan.md.
Structs§
- JitBucket
- A planned bucket with the partition specs grouped from its blocks.
- JitPartition
Config - Configuration for Just-In-Time (JIT) partition generation.
- Partition
Freshness Row - One
lakehouse_partitionscandidate row, as fetched byfetch_freshness_candidates:(begin_insert_time, end_insert_time, file_schema_hash, source_data_hash, file_size). Fields arepubsoanalytics/tests/can build rows directly, without a live database.
Enums§
- Block
Order - How source blocks are ordered before being cut into JIT partitions.
- Bucket
Sizing - How insert-time buckets are sized.
- Conflict
Retry - What to do after a mandatory write lost an overlap race.
- Coverage
- What a bucket needs: nothing, or its specs written with the given retire mode.
- Range
Convention - How a partition row’s insert range relates to a half-open bucket, which depends on who wrote the row.
Functions§
- batch_
windows - Packs consecutive planned buckets into batch query windows, greedily closing a window just
before it would exceed
target_rows_per_query. - blocks_
insert_ time_ range - Returns the real
[min, max]insert_timerange covered byblocks, independent of list order. Always use this instead of readingblocks[0]/blocks[last]: underBlockOrder::EventTimethe list is sorted by event time, not insert time, so its endpoints are no longer the insert-time extremes. - decide_
conflict_ retry - Decides what to do with a bucket whose write hit the no-overlap constraint, from the rows
fetched again afterwards. A concurrent writer that committed after the first retire SELECT is
listed in
refetched, so the retry’s retire mode is derived from it. - fetch_
freshness_ candidates - Fetches every
lakehouse_partitionsrow forview_metawhose insert range inclusively overlapsrange(begin_insert_time <= range.end AND end_insert_time >= range.begin), with the narrowing applied in Rust by the caller (spec_is_up_to_date,resolve_bucket_coverage). - fetch_
process_ blocks - Fetches and parses one batch window’s worth of process-scoped blocks (
process_batch_sql), looking up each block’s stream metadata instream_metadata(built once per call togenerate_process_jit_partitionsbyfetch_stream_metadata_map) rather than rebuilding it per row – this is the lean projection’s fetch-and-parse half. - generate_
process_ jit_ partitions - generate_process_jit_partitions lists the partitions that are needed to cover a time span for a specific process
these partitions may not exist or they could be out of date
Generates JIT partitions for a given time range filtered by process, grouped by the insert-time
bucket
plan_bucketsassigned them to. - generate_
stream_ jit_ partitions - generate_stream_jit_partitions lists the partitiions that are needed to cover a time span these partitions may not exist or they could be out of date Generates JIT partitions for a given time range.
- generate_
stream_ jit_ partitions_ segment - Generates a segment of JIT partitions.
- group_
blocks_ into_ partitions - Groups a segment’s source blocks into JIT partitions.
- group_
contiguous_ block_ chains - Splits an event-time-ordered block list into maximal chains whose tick coverage is unbroken, so
each chain can be decoded into one cross-block tree (a call tree for
thread_spans, a net span tree fornet_spans). - is_
jit_ partition_ up_ to_ date - is_jit_partition_up_to_date compares a partition spec with the partitions that exist to know if it should be recreated Checks if a JIT partition is up to date.
- process_
batch_ sql - The process-variant batch query: block columns plus
stream_idonly – no stream-level column (streams.dependencies_metadata/objects_metadata/tags/properties/format) may be added to theSELECTlist. Re-adding one would reintroduce the per-row stream-blob-copy memory hazard the lean projection removes, with no test failing except the projection guard inanalytics/tests/jit_batch_windows_tests.rs.array_has("streams.tags", ...)stays in theWHEREclause: filtering needs no projection. - resolve_
bucket_ coverage - Judges every bucket against the candidate rows and cascades: writing a stale bucket retires
rows (those inside its spec hulls for
Containment, those intersecting them forOverlap), which can strip coverage from a bucket that relied on one of them. Verdicts only move from covered to stale, so the loop ends in at mostbuckets.len()passes, and the query that triggers the writes never reads a bucket its own writes just emptied. - spec_
is_ up_ to_ date - Filters
candidatesdown to the rows with exactly the spec’s insert range, then applies therows.len() == 1/file_schema_hash/ exact object-count checks. Used by theBlockOrder::EventTimeviews (thread_spans/net_spans) only: their cut points can move betweenjit_updateruns, so a later run’s spec can be narrower than an already-written partition that still overlaps it, and an overlap test would call that stale, wider partition up to date and leave it in place forever. Exact equality reports “not up to date” instead, so the write falls through toRetireMatch::Overlap(seewrite_partition.rs). TheInsertTimeviews judge freshness per bucket withresolve_bucket_coverage. - update_
insert_ time_ jit_ view - Brings an
InsertTimeJIT view of one process up to date forquery_range: sizes buckets from the range, writes the stale ones, then promotes closed history to the range’s rung. - write_
partition_ from_ blocks - Writes a partition from a set of blocks, retiring the rows
retire_matchselects (seeRetireMatch;same_run_rangesis only meaningful forOverlap).