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

Function with_agg_accumulate

src/cypher/cypher.c:3903–3922  ·  view source on GitHub ↗

Accumulate aggregation values for a binding */

Source from the content-addressed store, hash-verified

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