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

Function with_proj_key

src/cypher/cypher.c:4054–4069  ·  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

4052/* Build a key from a projected vbinding's value tuple (all WITH output items),
4053 * used to detect duplicate rows for WITH DISTINCT (#238). */
4054static void with_proj_key(cbm_return_clause_t *wc, binding_t *b, char *key, size_t key_sz) {
4055 int kl = 0;
4056 key[0] = '\0';
4057 char name_buf[CBM_SZ_256];
4058 for (int ci = 0; ci < wc->count; ci++) {
4059 const char *alias = resolve_item_alias(&wc->items[ci], name_buf, sizeof(name_buf));
4060 const char *v = binding_get_virtual(b, alias, NULL);
4061 int w = snprintf(key + kl, (kl < (int)key_sz) ? key_sz - (size_t)kl : 0, "%s|", v ? v : "");
4062 if (w > 0) {
4063 kl += w;
4064 }
4065 if (kl >= (int)key_sz) {
4066 break; /* buffer full */
4067 }
4068 }
4069}
4070
4071/* Apply WITH DISTINCT: drop projected rows whose value tuple duplicates an
4072 * 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