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

Function cypher_expr_selectivity

src/cypher/cypher.c:5886–5904  ·  view source on GitHub ↗

Best equality on `var` reachable through AND alone. An AND chain is linked * along the right child (expr_chain_link), so the links are walked in a loop * and only each link's left operand recurses. */

Source from the content-addressed store, hash-verified

5884 * along the right child (expr_chain_link), so the links are walked in a loop
5885 * and only each link's left operand recurses. */
5886static int cypher_expr_selectivity(const cbm_expr_t *e, // NOLINT(misc-no-recursion)
5887 const char *var) {
5888 int best = 0;
5889 while (e) {
5890 if (e->type == EXPR_CONDITION) {
5891 int s = cypher_cond_selectivity(&e->cond, var);
5892 return s > best ? s : best;
5893 }
5894 if (e->type != EXPR_AND) {
5895 return best; /* OR / NOT / XOR: no single equality to seed from */
5896 }
5897 int l = cypher_expr_selectivity(e->left, var);
5898 if (l > best) {
5899 best = l;
5900 }
5901 e = e->right;
5902 }
5903 return best;
5904}
5905
5906static int cypher_node_selectivity(const cbm_node_pattern_t *n, const cbm_where_clause_t *w) {
5907 int s = 0;

Callers 1

cypher_node_selectivityFunction · 0.85

Calls 1

cypher_cond_selectivityFunction · 0.85

Tested by

no test coverage detected