pub trait PatternStats {
// Required methods
fn label_rows(&self, label: &NamedToken) -> Option<u64>;
fn equality_rows(
&self,
label: &NamedToken,
property: &NamedToken,
value: &Expr,
) -> Option<u64>;
fn contains_rows(
&self,
label: &NamedToken,
property: &NamedToken,
needle: &Expr,
) -> Option<ContainsCount>;
fn rel_type_rows(&self, rel_type: &NamedToken) -> Option<u64>;
// Provided methods
fn range_rows(
&self,
label: &NamedToken,
property: &NamedToken,
op: BinaryOp,
bound: &Expr,
) -> Option<u64> { ... }
fn key_stats(
&self,
_label: &NamedToken,
_property: &NamedToken,
) -> Option<Arc<KeyStats>> { ... }
fn equality_estimate(
&self,
_label: &NamedToken,
_property: &NamedToken,
_value: &Expr,
) -> Option<RowEstimate> { ... }
fn degree_tail(
&self,
label: &NamedToken,
rel_type: &NamedToken,
) -> Option<u64> { ... }
fn any_degree_tail(&self, rel_type: Option<&SmallName>) -> Option<u64> { ... }
fn degree_moments(
&self,
labels: &[NamedToken],
rel_types: &[NamedToken],
) -> Option<DegreeMoments> { ... }
fn in_degree_sum(
&self,
labels: &[NamedToken],
rel_types: &[NamedToken],
) -> Option<u128> { ... }
}Expand description
Live or stubbed counts used to estimate how many rows a pattern endpoint
produces. Every method returns None when that signal is unavailable,
which is not the same as zero rows. Labels and relationship types
arrive as a name beside its planning-time relate_names::Token
(ADR-0541): an implementor reads the id when planning resolved one and
falls back to the name only for an unresolved token.
Required Methods§
Sourcefn label_rows(&self, label: &NamedToken) -> Option<u64>
fn label_rows(&self, label: &NamedToken) -> Option<u64>
Nodes carrying label.
Sourcefn equality_rows(
&self,
label: &NamedToken,
property: &NamedToken,
value: &Expr,
) -> Option<u64>
fn equality_rows( &self, label: &NamedToken, property: &NamedToken, value: &Expr, ) -> Option<u64>
Hits of an equality seek on a RANGE index for (label, property).
value is the raw predicate expression. Implementors resolve
literals and parameters with Expr::seek_value and return None
for anything else. None also means no RANGE index, not zero hits.
Sourcefn contains_rows(
&self,
label: &NamedToken,
property: &NamedToken,
needle: &Expr,
) -> Option<ContainsCount>
fn contains_rows( &self, label: &NamedToken, property: &NamedToken, needle: &Expr, ) -> Option<ContainsCount>
Candidates of a CONTAINS filter on (label, property), with the
provenance that says how the count was measured (LABS-643): the
exact hits a TEXT index answered, or — without one — the sampled
estimate carrying the whole-label scan rows the unseekable filter
still pays. needle is the raw predicate expression. Implementors
resolve literals and parameters with Expr::seek_value and
return None for anything else. None means the count is
unmeasurable (a non-string needle), not zero candidates.
Sourcefn rel_type_rows(&self, rel_type: &NamedToken) -> Option<u64>
fn rel_type_rows(&self, rel_type: &NamedToken) -> Option<u64>
Relationships of rel_type.
Provided Methods§
Sourcefn range_rows(
&self,
label: &NamedToken,
property: &NamedToken,
op: BinaryOp,
bound: &Expr,
) -> Option<u64>
fn range_rows( &self, label: &NamedToken, property: &NamedToken, op: BinaryOp, bound: &Expr, ) -> Option<u64>
Hits of a comparison predicate (<, <=, >, >=) on a RANGE
index for (label, property) — the range window (ADR-0486). The
four comparison ops only: = stays PatternStats::equality_rows’s
domain, and IN and STARTS WITH are deferred. bound is the raw
predicate expression; implementors resolve literals and parameters
with Expr::seek_value and return None for anything else.
None also means no RANGE index on the pair, no order key on the
bound, or unbounded temporal postings — the executor seek’s own
decline conditions, spelled once by the index layer — never zero
hits.
Sourcefn key_stats(
&self,
_label: &NamedToken,
_property: &NamedToken,
) -> Option<Arc<KeyStats>>
fn key_stats( &self, _label: &NamedToken, _property: &NamedToken, ) -> Option<Arc<KeyStats>>
The value statistics of property over label’s nodes (the
per-key statistics ADR): count, distinct, minimum, maximum, sum and
the heavy values, with their Provenance. None means
unmeasured: the label’s statistics are not built yet, the key was
declined or evicted, or the pair is unresolved — never zero rows.
Sourcefn equality_estimate(
&self,
_label: &NamedToken,
_property: &NamedToken,
_value: &Expr,
) -> Option<RowEstimate>
fn equality_estimate( &self, _label: &NamedToken, _property: &NamedToken, _value: &Expr, ) -> Option<RowEstimate>
Rows an equality of property on label against value selects,
from the key’s statistics (or an index or built pair that answers
exactly), with the provenance of the answer. value is the raw
predicate expression; implementors resolve literals and parameters
with Expr::seek_value and return None for anything else.
Unlike PatternStats::equality_rows, which needs an index, this
prices an unindexed key too; None means unmeasured.
Sourcefn degree_tail(&self, label: &NamedToken, rel_type: &NamedToken) -> Option<u64>
fn degree_tail(&self, label: &NamedToken, rel_type: &NamedToken) -> Option<u64>
LABS-351: the tail of a (label, rel-type) out-degree distribution —
the conservative floor of the highest observed degree (a log2-bucket
histogram’s top bucket). None when the stats keep no histogram.
Consumed by apply_degree (LABS-426, the mean-to-tail flip): an
outgoing hop’s fanout rides the tail when the histogram has one,
the mean otherwise — the plan-choice consequence of the flip is
the measured part of that change.
Sourcefn any_degree_tail(&self, rel_type: Option<&SmallName>) -> Option<u64>
fn any_degree_tail(&self, rel_type: Option<&SmallName>) -> Option<u64>
LABS-991: the out-degree tail over every labeled node — the
log2-bucket floor of the highest observed degree of rel_type
(for None, of any relationship: the per-type tails summed, the
same floor scale, not a strict upper bound). The estimate a hop leaving
an unlabeled node, or crossing an untyped rel, rides when
PatternStats::degree_tail has no (label, type) pair to name.
Nodes carrying no label sit in no histogram and are not covered.
None when the stats keep no histogram.
Sourcefn degree_moments(
&self,
labels: &[NamedToken],
rel_types: &[NamedToken],
) -> Option<DegreeMoments>
fn degree_moments( &self, labels: &[NamedToken], rel_types: &[NamedToken], ) -> Option<DegreeMoments>
The out-degree moments (DegreeMoments) of nodes carrying the
labels in labels (empty: every labeled node; several: a bound,
the smallest per-label moments) over the rel types
rel_types (empty: every type). A name the store never interned
selects nothing, so its moments are zero. None when the stats
keep no histogram.
Sourcefn in_degree_sum(
&self,
labels: &[NamedToken],
rel_types: &[NamedToken],
) -> Option<u128>
fn in_degree_sum( &self, labels: &[NamedToken], rel_types: &[NamedToken], ) -> Option<u128>
The estimated sum of in-degrees — the relationships arriving at
nodes carrying the labels in labels (empty: every labeled node;
several: a bound, the smallest per-label sum) over the rel types
rel_types (empty: every type). The incoming side of
PatternStats::degree_moments’ sum, which an undirected or
incoming first hop needs: a label whose rels all point at it has
no out-degree. None when the stats keep no pair counts.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".