1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! Relationship equality seeks over the overlay (ADR-0185): the committed
//! graph's lazy relationship postings plus the scratch twin.
use relate_core::{RelId, Value};
use super::ExecGraph;
impl<'a> ExecGraph<'a> {
/// Candidate ids for a relationship uniqueness probe on
/// `(rel_type, key) = value` (ADR-0185), ascending and deduplicated: the
/// committed graph's lazy equality postings for the pair plus the
/// scratch's `rel_prop_ix` seek, merged through
/// [`ExecGraph::merged_candidates`]. A superset — the caller re-verifies
/// every id on this view. Empty when `value` has no property-index key
/// (it contains a NaN).
pub(crate) fn rel_equality_candidates(
&self,
rel_type: &str,
key: &str,
value: &Value,
) -> Vec<RelId> {
self.merged_candidates(self.base.rel_equality_postings(rel_type, key, value), |s| {
s.batch
.rel_prop_ix
.seek(&s.batch.rels, rel_type, key, value)
})
}
/// The committed-plus-scratch bucket length for `(rel_type, key) = value`
/// (ADR-0184, ADR-0185), for choosing the smallest bucket: the committed
/// postings' length plus the scratch seek's length, both counted in
/// place through [`ExecGraph::merged_len`].
pub(crate) fn rel_equality_bucket_len(
&self,
rel_type: &str,
key: &str,
value: &Value,
) -> usize {
self.merged_len(
self.base.rel_equality_postings_len(rel_type, key, value),
|s| {
s.batch
.rel_prop_ix
.seek_len(&s.batch.rels, rel_type, key, value)
},
)
}
}
#[cfg(test)]
mod tests;