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

Function rb_order_compare_rows

src/cypher/cypher.c:3902–3918  ·  view source on GitHub ↗

One ORDER BY comparison: numeric columns by their (int)strtol value, * others by strcmp, a later key breaking ties; positive = a after b. * va/vb are the rows' parsed numeric keys, or NULL to parse here. */

Source from the content-addressed store, hash-verified

3900 * others by strcmp, a later key breaking ties; positive = a after b.
3901 * va/vb are the rows' parsed numeric keys, or NULL to parse here. */
3902static int rb_order_compare_rows(const rb_order_ctx_t *ctx, const char **ra, const char **rb_row,
3903 const int *va, const int *vb) {
3904 int cmp = 0;
3905 for (int k = 0; k < ctx->keys && cmp == 0; k++) {
3906 if (ctx->numeric[k]) {
3907 int a = va ? va[k] : (int)strtol(ra[ctx->cols[k]], NULL, CBM_DECIMAL_BASE);
3908 int b = vb ? vb[k] : (int)strtol(rb_row[ctx->cols[k]], NULL, CBM_DECIMAL_BASE);
3909 cmp = (a > b) - (a < b);
3910 } else {
3911 cmp = strcmp(ra[ctx->cols[k]], rb_row[ctx->cols[k]]);
3912 }
3913 if (ctx->descs[k]) {
3914 cmp = -cmp;
3915 }
3916 }
3917 return cmp;
3918}
3919
3920static int rb_order_compare(const void *context, int a, int b) {
3921 const rb_order_ctx_t *ctx = context;

Callers 2

rb_order_compareFunction · 0.85
rb_apply_order_byFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected