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

Function count

src/expr/src/relation/func.rs:195–211  ·  view source on GitHub ↗
(datums: I)

Source from the content-addressed store, hash-verified

193}
194
195fn count<'a, I>(datums: I) -> Datum<'a>
196where
197 I: IntoIterator<Item = (Datum<'a>, Diff)>,
198{
199 // Count is accumulable: rather than expand each `(datum, diff)` into `diff`
200 // copies and count them, we sum the diffs directly. A net-negative count is
201 // possible (the surface does not define behavior in that case) and surfaces
202 // here as a negative result.
203 // TODO(jkosh44) This should error when the count can't fit inside of an `i64` instead of returning a negative result.
204 let mut count = Diff::ZERO;
205 for (datum, diff) in datums {
206 if !datum.is_null() {
207 count += diff;
208 }
209 }
210 Datum::from(count.into_inner())
211}
212
213fn any<'a, I>(datums: I) -> Datum<'a>
214where

Callers 1

evalMethod · 0.85

Calls 2

is_nullMethod · 0.45
into_innerMethod · 0.45

Tested by

no test coverage detected