rudb_exec/register.rs
1//! The one place every seam registry in the process is assembled.
2//!
3//! Registration is an explicit call in an explicit file, not a linker trick and not a macro that
4//! collects implementations behind the reader's back. The list is a public artifact: `EXPLAIN`
5//! prints from it, `rudb_strategies()` reads it, and `rudb-bench sweep --seam` enumerates it. A
6//! list that is assembled by magic is a list nobody can check, and the first question about a
7//! benchmark number is what produced it.
8//!
9//! This file is where a researcher who has written an implementation adds their one line. The rest
10//! of their work is one file in one crate behind one seam trait.
11//!
12//! # Why it is empty
13//!
14//! Nothing is registered yet. Twenty seven seams are named in `SeamId` and none of them has two
15//! implementations in the tree, because F0 is the skeleton and every seam's first two
16//! implementations belong to a later milestone, which [`SeamId::milestone`](rudb_seam::SeamId) says
17//! for each of them. `rudb_strategies()` prints those twenty seven rows with the implementation
18//! columns null, which is the honest state of the project and is meant to be read as a list of what
19//! is planned rather than as an empty table.
20
21use std::sync::OnceLock;
22
23use rudb_seam::Registries;
24
25/// Every registry in the process, assembled the first time somebody asks.
26///
27/// Built once and immutable after. A registry that could gain an entry after a query has planned
28/// against it is a registry that makes two runs of the same query incomparable, and comparing runs
29/// is the entire point of having one.
30///
31/// Public because `EXPLAIN` prints the seam section out of it and `EXPLAIN` is rendered above this
32/// crate, in `rudb`. The optimizer cannot reach it, being under this crate in the layer rule, so the
33/// caller that has both hands it over.
34pub fn registries() -> &'static Registries {
35 static REGISTRIES: OnceLock<Registries> = OnceLock::new();
36 REGISTRIES.get_or_init(assemble)
37}
38
39/// One line per crate that owns implementations of a seam.
40fn assemble() -> Registries {
41 // Each line below will read `registries.add(Arc::new(rudb_vector::register()))` or its
42 // equivalent for the crate that owns the seam. The first of them arrives with F1, which owes
43 // the vector form, compare, filter and expression evaluation seams their first two
44 // implementations each.
45 Registries::new()
46}