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

Function with_order_compare

src/cypher/cypher.c:4458–4475  ·  view source on GitHub ↗

The same comparison on values resolved once per binding. order_key_value * may return a rotating thread-local buffer, so the values are copies. */

Source from the content-addressed store, hash-verified

4456/* The same comparison on values resolved once per binding. order_key_value
4457 * may return a rotating thread-local buffer, so the values are copies. */
4458static int with_order_compare(const void *context, int a, int b) {
4459 const with_order_ctx_t *ctx = context;
4460 size_t keys = (size_t)ctx->wc->order_key_count;
4461 int cmp = 0;
4462 for (size_t k = 0; k < keys && cmp == 0; k++) {
4463 size_t ia = (size_t)a * keys + k;
4464 size_t ib = (size_t)b * keys + k;
4465 if (ctx->numbered[ia] && ctx->numbered[ib]) {
4466 cmp = (ctx->numbers[ia] > ctx->numbers[ib]) - (ctx->numbers[ia] < ctx->numbers[ib]);
4467 } else {
4468 cmp = strcmp(ctx->values[ia], ctx->values[ib]);
4469 }
4470 if (ctx->wc->order_descs[k]) {
4471 cmp = -cmp;
4472 }
4473 }
4474 return cmp;
4475}
4476
4477/* Sort bindings by the ORDER BY key list (virtual variables), stably. */
4478static void sort_bindings(binding_t *vbindings, int count, const cbm_return_clause_t *wc) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected