MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / find

Method find

src/expr/src/relation/canonicalize.rs:522–538  ·  view source on GitHub ↗
(&'a mut self, x: &T)

Source from the content-addressed store, hash-verified

520
521impl<T: Clone + Ord> UnionFind<T> for BTreeMap<T, T> {
522 fn find<'a>(&'a mut self, x: &T) -> Option<&'a T> {
523 if !self.contains_key(x) {
524 None
525 } else {
526 if self[x] != self[&self[x]] {
527 // Path halving
528 let mut y = self[x].clone();
529 while y != self[&y] {
530 let grandparent = self[&self[&y]].clone();
531 *self.get_mut(&y).unwrap() = grandparent;
532 y.clone_from(&self[&y]);
533 }
534 *self.get_mut(x).unwrap() = y;
535 }
536 Some(&self[x])
537 }
538 }
539
540 fn union(&mut self, x: &T, y: &T) {
541 match (self.find(x).is_some(), self.find(y).is_some()) {

Callers 15

strip_commentsFunction · 0.45
undistribute_and_orMethod · 0.45
unionMethod · 0.45
find_bound_exprMethod · 0.45
jsonb_get_stringFunction · 0.45
jsonb_get_pathFunction · 0.45
map_get_valueFunction · 0.45
regexp_match_staticFunction · 0.45
positionFunction · 0.45
array_create_multidimFunction · 0.45
execute_promsql_queryFunction · 0.45

Calls 5

contains_keyMethod · 0.80
unwrapMethod · 0.80
cloneMethod · 0.45
get_mutMethod · 0.45
clone_fromMethod · 0.45