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

Function cypher_node_selectivity

src/cypher/cypher.c:5906–5935  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5904}
5905
5906static int cypher_node_selectivity(const cbm_node_pattern_t *n, const cbm_where_clause_t *w) {
5907 int s = 0;
5908 for (int i = 0; i < n->prop_count; i++) {
5909 const char *k = n->props[i].key;
5910 int v = (k && (strcmp(k, "name") == 0 || strcmp(k, "qualified_name") == 0)) ? 3 : 2;
5911 if (v > s) {
5912 s = v;
5913 }
5914 }
5915 if (w && n->variable) {
5916 int v = 0;
5917 if (w->root) {
5918 v = cypher_expr_selectivity(w->root, n->variable);
5919 } else if (!w->op || strcmp(w->op, "AND") == 0) {
5920 for (int i = 0; i < w->count; i++) {
5921 int c = cypher_cond_selectivity(&w->conditions[i], n->variable);
5922 if (c > v) {
5923 v = c;
5924 }
5925 }
5926 }
5927 if (v > s) {
5928 s = v;
5929 }
5930 }
5931 if (s == 0 && n->label) {
5932 s = 1;
5933 }
5934 return s;
5935}
5936
5937static void cypher_plan_seed_from_selective_end(cbm_query_t *q) {
5938 if (!q || q->pattern_count != 1 || !q->ret || (q->pattern_optional && q->pattern_optional[0])) {

Callers 1

Calls 2

cypher_expr_selectivityFunction · 0.85
cypher_cond_selectivityFunction · 0.85

Tested by

no test coverage detected