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

Method evaluate

src/expr/src/linear.rs:1864–1970  ·  view source on GitHub ↗

Evaluate the predicates, temporal and non-, and return times and differences for `data`. If `self` contains only non-temporal predicates, the result will either be `(time, diff)`, or an evaluation error. If `self contains temporal predicates, the results can be times that are greater than the input `time`, and may contain negated `diff` values. The `row_builder` is not cleared first, but emptied

(
            &'a self,
            datums: &'b mut Vec<Datum<'a>>,
            arena: &'a RowArena,
            time: mz_repr::Timestamp,
            diff: Diff,
            valid_time: V,
          

Source from the content-addressed store, hash-verified

1862 /// The `row_builder` is not cleared first, but emptied if the function
1863 /// returns an iterator with any `Ok(_)` element.
1864 pub fn evaluate<'b, 'a: 'b, Err: From<EvalError>, V: Fn(&mz_repr::Timestamp) -> bool>(
1865 &'a self,
1866 datums: &'b mut Vec<Datum<'a>>,
1867 arena: &'a RowArena,
1868 time: mz_repr::Timestamp,
1869 diff: Diff,
1870 valid_time: V,
1871 row_builder: &mut Row,
1872 ) -> impl Iterator<
1873 Item = Result<(Row, mz_repr::Timestamp, Diff), (Err, mz_repr::Timestamp, Diff)>,
1874 > + use<Err, V, E> {
1875 match self.mfp.evaluate_inner(datums, arena) {
1876 Err(e) => {
1877 return Some(Err((e.into(), time, diff))).into_iter().chain(None);
1878 }
1879 Ok(true) => {}
1880 Ok(false) => {
1881 return None.into_iter().chain(None);
1882 }
1883 }
1884
1885 // Lower and upper bounds.
1886 let mut lower_bound = time;
1887 let mut upper_bound = None;
1888
1889 // Track whether we have seen a null in either bound, as this should
1890 // prevent the record from being produced at any time.
1891 let mut null_eval = false;
1892
1893 // Advance our lower bound to be at least the result of any lower bound
1894 // expressions.
1895 for l in self.lower_bounds.iter() {
1896 match l.eval(datums, arena) {
1897 Err(e) => {
1898 return Some(Err((e.into(), time, diff))).into_iter().chain(None);
1899 }
1900 Ok(Datum::MzTimestamp(d)) => {
1901 lower_bound = lower_bound.max(d);
1902 }
1903 Ok(Datum::Null) => {
1904 null_eval = true;
1905 }
1906 x => {
1907 panic!("Non-mz_timestamp value in temporal predicate: {:?}", x);
1908 }
1909 }
1910 }
1911
1912 // If the lower bound exceeds our `until` frontier, it should not appear in the output.
1913 if !valid_time(&lower_bound) {
1914 return None.into_iter().chain(None);
1915 }
1916
1917 // If there are any upper bounds, determine the minimum upper bound.
1918 for u in self.upper_bounds.iter() {
1919 // We can cease as soon as the lower and upper bounds match,
1920 // as the update will certainly not be produced in that case.
1921 if upper_bound != Some(lower_bound) {

Callers 5

platform.spec.tsFile · 0.80
prometheus.spec.tsFile · 0.80
do_workMethod · 0.80
drain_through_mfpFunction · 0.80
as_collection_coreMethod · 0.80

Calls 11

evaluate_innerMethod · 0.80
minMethod · 0.80
is_someMethod · 0.80
packerMethod · 0.80
into_iterMethod · 0.45
iterMethod · 0.45
evalMethod · 0.45
maxMethod · 0.45
extendMethod · 0.45
mapMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected