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

Function rb_apply_distinct

src/cypher/cypher.c:3147–3178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3145}
3146
3147static void rb_apply_distinct(result_builder_t *rb) {
3148 if (rb->row_count <= SKIP_ONE) {
3149 return;
3150 }
3151 int kept = SKIP_ONE;
3152 for (int i = SKIP_ONE; i < rb->row_count; i++) {
3153 bool dup = false;
3154 for (int j = 0; j < kept && !dup; j++) {
3155 bool same = true;
3156 for (int c = 0; c < rb->col_count && same; c++) {
3157 if (strcmp(rb->rows[i][c], rb->rows[j][c]) != 0) {
3158 same = false;
3159 }
3160 }
3161 if (same) {
3162 dup = true;
3163 }
3164 }
3165 if (!dup) {
3166 if (kept != i) {
3167 rb->rows[kept] = rb->rows[i];
3168 }
3169 kept++;
3170 } else {
3171 for (int c = 0; c < rb->col_count; c++) {
3172 safe_str_free(&rb->rows[i][c]);
3173 }
3174 free(rb->rows[i]);
3175 }
3176 }
3177 rb->row_count = kept;
3178}
3179
3180static void rb_free(result_builder_t *rb) {
3181 for (int i = 0; i < rb->row_count; i++) {

Callers 2

execute_return_clauseFunction · 0.85
cbm_cypher_executeFunction · 0.85

Calls 1

safe_str_freeFunction · 0.85

Tested by

no test coverage detected