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

Function ref_first_occurrences

tests/test_cypher.c:5724–5740  ·  view source on GitHub ↗

`got` must be the first occurrence of every value in column 0 of `all`. */

Source from the content-addressed store, hash-verified

5722
5723/* `got` must be the first occurrence of every value in column 0 of `all`. */
5724static bool ref_first_occurrences(const cbm_cypher_result_t *got, const cbm_cypher_result_t *all) {
5725 int kept = 0;
5726 for (int i = 0; i < all->row_count; i++) {
5727 bool seen = false;
5728 for (int j = 0; j < i && !seen; j++) {
5729 seen = strcmp(all->rows[i][0], all->rows[j][0]) == 0;
5730 }
5731 if (seen) {
5732 continue;
5733 }
5734 if (kept >= got->row_count || strcmp(got->rows[kept][0], all->rows[i][0]) != 0) {
5735 return false;
5736 }
5737 kept++;
5738 }
5739 return kept == got->row_count;
5740}
5741
5742TEST(cypher_distinct_keeps_first_occurrences) {
5743 cbm_store_t *s = setup_reference_store();

Callers 1

test_cypher.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected