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

Function ret_agg_emit_row

src/cypher/cypher.c:4374–4394  ·  view source on GitHub ↗

Emit one aggregated row into the result builder */

Source from the content-addressed store, hash-verified

4372
4373/* Emit one aggregated row into the result builder */
4374static void ret_agg_emit_row(cbm_return_clause_t *ret, ret_agg_entry_t *agg, result_builder_t *rb) {
4375 const char *row[CBM_SZ_32];
4376 char bufs[CBM_SZ_32][CBM_SZ_64];
4377 for (int ci = 0; ci < ret->count; ci++) {
4378 if (!is_aggregate_func(ret->items[ci].func)) {
4379 row[ci] = agg->group_vals[ci];
4380 continue;
4381 }
4382 if (ret->items[ci].distinct && strcmp(ret->items[ci].func, "COUNT") == 0) {
4383 /* COUNT(DISTINCT x) — number of unique values accumulated (#239). */
4384 snprintf(bufs[ci], sizeof(bufs[ci]), "%d", agg->collect_counts[ci]);
4385 row[ci] = bufs[ci];
4386 continue;
4387 }
4388 format_agg_value(ret->items[ci].func, agg->counts[ci], agg->sums[ci], agg->mins[ci],
4389 agg->maxs[ci], agg->collect_lists, agg->collect_counts, ci, bufs[ci],
4390 sizeof(bufs[ci]));
4391 row[ci] = bufs[ci];
4392 }
4393 rb_add_row(rb, row);
4394}
4395
4396static void execute_return_agg(cbm_return_clause_t *ret, binding_t *bindings, int bind_count,
4397 result_builder_t *rb) {

Callers 1

execute_return_aggFunction · 0.85

Calls 3

is_aggregate_funcFunction · 0.85
format_agg_valueFunction · 0.85
rb_add_rowFunction · 0.85

Tested by

no test coverage detected