MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / single_cell

Function single_cell

nodedb-array/src/query/aggregate.rs:146–162  ·  view source on GitHub ↗
(v: &CellValue, reducer: Reducer)

Source from the content-addressed store, hash-verified

144}
145
146fn single_cell(v: &CellValue, reducer: Reducer) -> AggregateResult {
147 use AggregateResult::*;
148 let n = match v {
149 CellValue::Int64(x) => Some(*x as f64),
150 CellValue::Float64(x) => Some(*x),
151 CellValue::String(_) | CellValue::Bytes(_) | CellValue::Null => None,
152 };
153 match (reducer, n) {
154 (Reducer::Count, _) if !v.is_null() => Count { count: 1 },
155 (Reducer::Count, _) => Empty(Reducer::Count),
156 (Reducer::Sum, Some(x)) => Sum { value: x, count: 1 },
157 (Reducer::Min, Some(x)) => Min { value: x, count: 1 },
158 (Reducer::Max, Some(x)) => Max { value: x, count: 1 },
159 (Reducer::Mean, Some(x)) => Mean { sum: x, count: 1 },
160 (r, None) => Empty(r),
161 }
162}
163
164/// One bucket of a group-by aggregate. The key is the dim value the
165/// rows share; `result` is the reducer's running partial over that

Callers 2

aggregate_attrFunction · 0.85
group_by_dimFunction · 0.85

Calls 1

is_nullMethod · 0.45

Tested by

no test coverage detected