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

Function ret_agg_init_group

src/cypher/cypher.c:5212–5232  ·  view source on GitHub ↗

Initialize a new RETURN aggregation group */

Source from the content-addressed store, hash-verified

5210
5211/* Initialize a new RETURN aggregation group */
5212static void ret_agg_init_group(ret_agg_entry_t *entry, const char *key, int item_count,
5213 const char **vals) {
5214 snprintf(entry->group_key, sizeof(entry->group_key), "%s", key);
5215 entry->group_vals = calloc(item_count, sizeof(const char *));
5216 entry->sums = calloc(item_count, sizeof(double));
5217 entry->counts = calloc(item_count, sizeof(int));
5218 /* calloc: the sentinel loop below overwrites every slot, but the bound
5219 * equality with the accumulate loop is invisible to path-sensitive
5220 * analysis; zeroed backing keeps any modeled mismatch defined. */
5221 entry->mins = calloc(item_count, sizeof(double));
5222 entry->maxs = calloc(item_count, sizeof(double));
5223 entry->collect_lists = calloc(item_count, sizeof(char **));
5224 entry->collect_counts = calloc(item_count, sizeof(int));
5225 entry->distinct_sets =
5226 cbm_calloc(CBM_MEM_CLASS_OTHER, (size_t)item_count * sizeof(CBMHashTable *));
5227 for (int ci = 0; ci < item_count; ci++) {
5228 entry->mins[ci] = CYP_DBL_MAX;
5229 entry->maxs[ci] = -CYP_DBL_MAX;
5230 entry->group_vals[ci] = heap_strdup(vals[ci]);
5231 }
5232}
5233
5234/* Accumulate a binding into RETURN aggregation */
5235static bool binding_has_value(binding_t *b, const char *var, const char *prop) {

Callers 1

ret_sink_feed_aggFunction · 0.85

Calls 2

cbm_callocFunction · 0.85
heap_strdupFunction · 0.70

Tested by

no test coverage detected