pub fn unifies_its_own_contributions(
node: &NativeNode,
source_tags: &[Vec<String>],
source_metrics: &[Option<Arc<str>>],
) -> Option<bool>Expand description
Whether node hands over one logical series per canonical label set, or several.
This is the rule the runtime collectors use to decide whether a consumer above node has to
collect what node emits. RuntimeNode::build in execute and the
Window and limitk collectors share this predicate so their decisions cannot disagree.
Three answers, because what a consumer may do about a contribution carries two facts and a boundary answers neither:
Some(true): the output is one series per canonical label set, established here, so a consumer that needs one unified series already has it and collects nothing.Some(false): the output may hold several series of one label set, and this node says so, so a consumer that needs one unified series collects them throughMergeInput. ANativeExpr::Mergeabove such a node would make it stream an already-merged series and turn that collection off.None: the output may hold several, and this node says nothing: it has neither a proof to offer nor a report to make. Only a boundary (NativeExpr::Input) answers this, and a node that hands its input’s series back unchanged passes the answer on. Runtime collectors leave this case alone because they collect only when the answer isSome(false).
The collection condition is matches!(answer, Some(false)): the Window MergeInput collector
at runtime and the limitk collector both ask this predicate of their input.
source_tags and source_metrics are the same facts
duplicates_canonical_labels judges a whole label set by, indexed the same way: a node that
drops the metadata labels reports fragments only when
metadata_labels_keep_series_apart cannot prove the labels tell its series apart. That is the
whole of the drop’s proof, so this predicate and the canonical pass cannot disagree about a drop:
a NULL/'' pair in one key column is outside it for both, and the statements the pair leaves
unproved are counted by leaves_a_drop_to_the_storage_keys rather than collected.
This predicate is only ever asked of a node by the consumer directly above it - the Window
MergeInput collector and the limitk one, both in execute - and
that is exactly where the canonical pass puts its NativeExpr::Merge when a collection is
needed: it collects the input of a Window, an Aggregate, a Vector, a Map, a
ParameterizedMap and each side of a Binary/Set/Info
(merge_label_rewrites). The collector
then reads the merge’s Some(true) - a merge is the collection - so the weaker answer this
function gives about the node beneath it is never the one acted on. Where the pass left the tree
alone, the proof held, and the answer asked here is the same one. A caller without these facts
(placement, which reads a tree without a binding) passes empty slices and gets the conservative
answer.