Reduce one attr column over all rows of a tile. `attr_idx` must be in range; non-numeric / null cells are skipped (Count includes non-null cells regardless of dtype, since "count of cells with this attribute populated" is a sensible fold across all attr types).
(tile: &SparseTile, attr_idx: usize, reducer: Reducer)
| 132 | /// non-null cells regardless of dtype, since "count of cells with this |
| 133 | /// attribute populated" is a sensible fold across all attr types). |
| 134 | pub fn aggregate_attr(tile: &SparseTile, attr_idx: usize, reducer: Reducer) -> AggregateResult { |
| 135 | let Some(col) = tile.attr_cols.get(attr_idx) else { |
| 136 | return empty(reducer); |
| 137 | }; |
| 138 | let mut acc = empty(reducer); |
| 139 | for v in col { |
| 140 | let one = single_cell(v, reducer); |
| 141 | acc = acc.merge(one); |
| 142 | } |
| 143 | acc |
| 144 | } |
| 145 | |
| 146 | fn single_cell(v: &CellValue, reducer: Reducer) -> AggregateResult { |
| 147 | use AggregateResult::*; |