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

Function with_proj_key

src/cypher/cypher.c:3714–3729  ·  view source on GitHub ↗

Build a key from a projected vbinding's value tuple (all WITH output items), * used to detect duplicate rows for WITH DISTINCT (#238). */

Source from the content-addressed store, hash-verified

3712/* Build a key from a projected vbinding's value tuple (all WITH output items),
3713 * used to detect duplicate rows for WITH DISTINCT (#238). */
3714static void with_proj_key(cbm_return_clause_t *wc, binding_t *b, char *key, size_t key_sz) {
3715 int kl = 0;
3716 key[0] = '\0';
3717 char name_buf[CBM_SZ_256];
3718 for (int ci = 0; ci < wc->count; ci++) {
3719 const char *alias = resolve_item_alias(&wc->items[ci], name_buf, sizeof(name_buf));
3720 const char *v = binding_get_virtual(b, alias, NULL);
3721 int w = snprintf(key + kl, (kl < (int)key_sz) ? key_sz - (size_t)kl : 0, "%s|", v ? v : "");
3722 if (w > 0) {
3723 kl += w;
3724 }
3725 if (kl >= (int)key_sz) {
3726 break; /* buffer full */
3727 }
3728 }
3729}
3730
3731/* Apply WITH DISTINCT: drop projected rows whose value tuple duplicates an
3732 * earlier one, keeping first occurrence (#238 — previously silently ignored). */

Callers 1

with_apply_distinctFunction · 0.85

Calls 2

resolve_item_aliasFunction · 0.85
binding_get_virtualFunction · 0.85

Tested by

no test coverage detected