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

Method filter

src/expr/src/linear.rs:131–163  ·  view source on GitHub ↗

Retain only rows satisfying these predicates. This method introduces predicates as eagerly as they can be evaluated, which may not be desired for predicates that may cause exceptions. If fine manipulation is required, the predicates can be added manually.

(mut self, predicates: I)

Source from the content-addressed store, hash-verified

129 /// which may not be desired for predicates that may cause exceptions.
130 /// If fine manipulation is required, the predicates can be added manually.
131 pub fn filter<I>(mut self, predicates: I) -> Self
132 where
133 I: IntoIterator<Item = E>,
134 {
135 for mut predicate in predicates {
136 // Correct column references.
137 predicate.permute(&self.projection[..]);
138
139 // Validate column references.
140 assert!(
141 predicate
142 .support()
143 .into_iter()
144 .all(|c| c < self.input_arity + self.expressions.len())
145 );
146
147 // Insert predicate as eagerly as it can be evaluated:
148 // just after the largest column in its support is formed.
149 let max_support = predicate
150 .support()
151 .into_iter()
152 .max()
153 .map(|c| c + 1)
154 .unwrap_or(0);
155 self.predicates.push((max_support, predicate))
156 }
157 // Stable sort predicates by position at which they take effect.
158 // We put literal errors at the end as a stop-gap to avoid erroring
159 // before we are able to evaluate any predicates that might prevent it.
160 self.predicates
161 .sort_by_key(|(position, predicate)| (E::is_literal_err(predicate), *position));
162 self
163 }
164
165 /// Append the result of evaluating expressions to each row.
166 pub fn map<I>(mut self, expressions: I) -> Self

Callers 15

requireEnvFunction · 0.45
svgrTemplateFunction · 0.45
labelFromQueryKeyFunction · 0.45
labelRequestFunction · 0.45
printQuerySummaryFunction · 0.45
printConcurrencySummaryFunction · 0.45
printPerTabSummaryFunction · 0.45
auditPageFunction · 0.45
buildRegexFunction · 0.45
highlightWordsFunction · 0.45

Calls 7

sort_by_keyMethod · 0.80
permuteMethod · 0.45
mapMethod · 0.45
maxMethod · 0.45
into_iterMethod · 0.45
supportMethod · 0.45
pushMethod · 0.45

Tested by 15

auditPageFunction · 0.36
buildDataFunction · 0.36
test_mfpFunction · 0.36
test_interpretFunction · 0.36
storage_frontiersMethod · 0.36
test_http_metricsFunction · 0.36