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

Function with_agg_accumulate

src/cypher/cypher.c:3898–3917  ·  view source on GitHub ↗

Accumulate aggregation values for a binding */

Source from the content-addressed store, hash-verified

3896
3897/* Accumulate aggregation values for a binding */
3898static void with_agg_accumulate(with_agg_t *agg, cbm_return_clause_t *wc, binding_t *b) {
3899 for (int ci = 0; ci < wc->count; ci++) {
3900 if (!is_aggregate_func(wc->items[ci].func)) {
3901 continue;
3902 }
3903 agg->counts[ci]++;
3904 const char *raw = binding_get_virtual(b, wc->items[ci].variable, wc->items[ci].property);
3905 if (wc->items[ci].distinct && strcmp(wc->items[ci].func, "COUNT") == 0) {
3906 distinct_list_add(&agg->distinct_lists[ci], &agg->distinct_n[ci], raw);
3907 }
3908 double dv = strtod(raw, NULL);
3909 agg->sums[ci] += dv;
3910 if (dv < agg->mins[ci]) {
3911 agg->mins[ci] = dv;
3912 }
3913 if (dv > agg->maxs[ci]) {
3914 agg->maxs[ci] = dv;
3915 }
3916 }
3917}
3918
3919/* Format a WITH aggregation value into buf */
3920static 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 3

is_aggregate_funcFunction · 0.85
binding_get_virtualFunction · 0.85
distinct_list_addFunction · 0.85

Tested by

no test coverage detected