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

Function aggregate_attr

nodedb-array/src/query/aggregate.rs:134–144  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

132/// non-null cells regardless of dtype, since "count of cells with this
133/// attribute populated" is a sensible fold across all attr types).
134pub 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
146fn single_cell(v: &CellValue, reducer: Reducer) -> AggregateResult {
147 use AggregateResult::*;

Calls 4

single_cellFunction · 0.85
emptyFunction · 0.70
getMethod · 0.45
mergeMethod · 0.45

Tested by 3

sum_skips_nullsFunction · 0.68