(v: &CellValue, reducer: Reducer)
| 144 | } |
| 145 | |
| 146 | fn 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 |
no test coverage detected