pub fn estimate_join_key_domain(
profile: &StatsProfile,
pattern: &EncodedTriplePattern,
slot: JoinKeySlot,
) -> Option<u64>Expand description
Distinct-value domain for a join variable in slot, from predicate HLLs.
rdf:type exception: for the subject slot of a ?s rdf:type Class
pattern with a bound named class, the exact class_counts entry IS the
domain — the per-predicate HLL cannot condition on the bound object and
would answer “distinct subjects with any type”, routinely overstating
a 5-instance class by the whole typed-subject population. A missing or
zero class count falls back to the HLL rather than reporting 0 (a
never-observed class arguably proves an empty join, but turning that
into zero-row plan substitutions is a separate, deliberate rewrite).
Note class_counts counts visible type-triples (rows), which overstates
distinct subjects only when one subject carries the class in several
graphs; callers cap with min(domain, rows) so the skew degrades
gracefully.
rdf:type object exception: for the object slot of an open
?s rdf:type ?cls pattern, class_counts.len() IS the distinct-class
domain when the exact map is non-empty. The objects HLL answers the same
question approximately (± sketch error, insert-biased after deletes,
admits non-named objects) and can be trimmed by the wire cap
(class_counts never is), so exact wins whenever it exists.
Returns None when the predicate is unbound or has no HLL sketch yet
(and no exact class count applied).