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

Function cbm_store_node_scan_open

src/store/store.c:3466–3498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3464}
3465
3466cbm_store_node_scan_t *cbm_store_node_scan_open(cbm_store_t *s, const char *project,
3467 const char *label) {
3468 if (!s || !s->db) {
3469 return NULL;
3470 }
3471 cbm_store_node_scan_t *scan = cbm_calloc(CBM_MEM_CLASS_STORE, sizeof(*scan));
3472 if (!scan) {
3473 return NULL;
3474 }
3475 scan->store = s;
3476 scan->project = cbm_mem_strdup(CBM_MEM_CLASS_STORE, project);
3477 scan->label = cbm_mem_strdup(CBM_MEM_CLASS_STORE, label);
3478 if ((project && !scan->project) || (label && !scan->label)) {
3479 cbm_store_node_scan_close(scan);
3480 return NULL;
3481 }
3482 scan->phase = label ? NODE_SCAN_LABEL : NODE_SCAN_NULL_FILE; /* NULL file_path rows first */
3483 if (label) {
3484 scan->paged =
3485 node_scan_plan_is(s, NODE_SCAN_COLS "WHERE project = ?1 AND label = ?2;",
3486 "SEARCH nodes USING INDEX idx_nodes_label (project=? AND label=?)");
3487 } else {
3488 scan->paged = node_scan_plan_is(s, NODE_SCAN_COLS "WHERE project = ?1;",
3489 "SEARCH nodes USING INDEX idx_nodes_file (project=?)");
3490 }
3491 if (!scan->paged) {
3492 int rc = label ? cbm_store_find_nodes_by_label(s, project, label, &scan->eager,
3493 &scan->eager_count)
3494 : cbm_store_find_nodes(s, project, &scan->eager, &scan->eager_count);
3495 scan->eager_failed = rc != CBM_STORE_OK;
3496 }
3497 return scan;
3498}
3499
3500bool cbm_store_node_scan_paged(const cbm_store_node_scan_t *scan) {
3501 return scan && scan->paged;

Callers 3

start_source_openFunction · 0.85
start_source_next_labelFunction · 0.85
scan_matches_eagerFunction · 0.85

Calls 6

cbm_callocFunction · 0.85
cbm_mem_strdupFunction · 0.85
node_scan_plan_isFunction · 0.85
cbm_store_find_nodesFunction · 0.85

Tested by 1

scan_matches_eagerFunction · 0.68