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

Function with_proj_key

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

4921/* Build a key from a projected vbinding's value tuple (all WITH output items),
4922 * used to detect duplicate rows for WITH DISTINCT (#238). */
4923static void with_proj_key(cbm_return_clause_t *wc, binding_t *b, char *key, size_t key_sz) {
4924 int kl = 0;
4925 key[0] = '\0';
4926 char name_buf[CBM_SZ_256];
4927 for (int ci = 0; ci < wc->count; ci++) {
4928 const char *alias = resolve_item_alias(&wc->items[ci], name_buf, sizeof(name_buf));
4929 const char *v = binding_get_virtual(b, alias, NULL);
4930 int w = snprintf(key + kl, (kl < (int)key_sz) ? key_sz - (size_t)kl : 0, "%s|", v ? v : "");
4931 if (w > 0) {
4932 kl += w;
4933 }
4934 if (kl >= (int)key_sz) {
4935 break; /* buffer full */
4936 }
4937 }
4938}
4939
4940/* Apply WITH DISTINCT: drop projected rows whose value tuple duplicates an
4941 * 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