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

Method intersect

src/expr/src/interpret.rs:81–106  ·  view source on GitHub ↗
(self, other: Values<'a>)

Source from the content-addressed store, hash-verified

79 }
80
81 fn intersect(self, other: Values<'a>) -> Values<'a> {
82 match (self, other) {
83 (Values::Empty, _) => Values::Empty,
84 (_, Values::Empty) => Values::Empty,
85 (Values::Within(a0, a1), Values::Within(b0, b1)) => {
86 let min = a0.max(b0);
87 let max = a1.min(b1);
88 if min <= max {
89 Values::Within(min, max)
90 } else {
91 Values::Empty
92 }
93 }
94 (Values::Nested(mut a), Values::Nested(b)) => {
95 for (datum, other_spec) in b {
96 let spec = a.entry(datum).or_insert_with(ResultSpec::anything);
97 *spec = spec.clone().intersect(other_spec);
98 }
99 Values::Nested(a)
100 }
101 (Values::All, v) => v,
102 (v, Values::All) => v,
103 (Values::Nested(_), Values::Within(_, _)) => Values::Empty,
104 (Values::Within(_, _), Values::Nested(_)) => Values::Empty,
105 }
106 }
107
108 fn may_contain(&self, value: Datum<'a>) -> bool {
109 match self {

Callers 8

eqMethod · 0.80
push_columnMethod · 0.80
push_unmaterializableMethod · 0.80
unaryMethod · 0.80
binaryMethod · 0.80
variadicMethod · 0.80
condMethod · 0.80
col_statsMethod · 0.80

Calls 4

minMethod · 0.80
maxMethod · 0.45
entryMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected