MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / with_agg_accumulate

Function with_agg_accumulate

src/cypher/cypher.c:3558–3577  ·  view source on GitHub ↗

Accumulate aggregation values for a binding */

Source from the content-addressed store, hash-verified

3556
3557/* Accumulate aggregation values for a binding */
3558static void with_agg_accumulate(with_agg_t *agg, cbm_return_clause_t *wc, binding_t *b) {
3559 for (int ci = 0; ci < wc->count; ci++) {
3560 if (!wc->items[ci].func) {
3561 continue;
3562 }
3563 agg->counts[ci]++;
3564 const char *raw = binding_get_virtual(b, wc->items[ci].variable, wc->items[ci].property);
3565 if (wc->items[ci].distinct && strcmp(wc->items[ci].func, "COUNT") == 0) {
3566 distinct_list_add(&agg->distinct_lists[ci], &agg->distinct_n[ci], raw);
3567 }
3568 double dv = strtod(raw, NULL);
3569 agg->sums[ci] += dv;
3570 if (dv < agg->mins[ci]) {
3571 agg->mins[ci] = dv;
3572 }
3573 if (dv > agg->maxs[ci]) {
3574 agg->maxs[ci] = dv;
3575 }
3576 }
3577}
3578
3579/* Format a WITH aggregation value into buf */
3580static void with_agg_format(const char *func, with_agg_t *agg, int ci, char *buf, size_t buf_sz) {

Callers 1

execute_with_aggregateFunction · 0.85

Calls 2

binding_get_virtualFunction · 0.85
distinct_list_addFunction · 0.85

Tested by

no test coverage detected