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

Function scan_matches_eager

tests/test_store_nodes.c:421–453  ·  view source on GitHub ↗

The streamed scan gives the eager scan's rows, field for field and in the * same order, at any batch size, while other lookups (including the eager * scans' own cached statements) run between batches. Returns the row count, * or -1 on the first difference; *paged tells whether the scan paged. */

Source from the content-addressed store, hash-verified

419 * scans' own cached statements) run between batches. Returns the row count,
420 * or -1 on the first difference; *paged tells whether the scan paged. */
421static int scan_matches_eager(cbm_store_t *s, const char *project, const char *label, int batch,
422 bool *paged) {
423 cbm_node_t *eager = NULL;
424 int n = 0;
425 int rc = label ? cbm_store_find_nodes_by_label(s, project, label, &eager, &n)
426 : cbm_store_find_nodes(s, project, &eager, &n);
427 if (rc != CBM_STORE_OK) {
428 return -1;
429 }
430 cbm_store_node_scan_t *scan = cbm_store_node_scan_open(s, project, label);
431 *paged = cbm_store_node_scan_paged(scan);
432 cbm_node_t buf[64];
433 int seen = 0;
434 bool same = scan != NULL && batch <= 64;
435 int got = 0;
436 while (same && cbm_store_node_scan_next(scan, buf, batch, &got) == CBM_STORE_OK && got > 0) {
437 for (int i = 0; i < got; i++, seen++) {
438 same = same && seen < n && scan_node_same(&buf[i], &eager[seen]);
439 cbm_node_free_fields(&buf[i]);
440 }
441 cbm_node_t *other = NULL;
442 int other_n = 0;
443 (void)cbm_store_find_nodes(s, project, &other, &other_n);
444 cbm_store_free_nodes(other, other_n);
445 (void)cbm_store_find_nodes_by_label(s, project, "Class", &other, &other_n);
446 cbm_store_free_nodes(other, other_n);
447 }
448 /* An exhausted scan stays exhausted. */
449 same = same && cbm_store_node_scan_next(scan, buf, batch, &got) == CBM_STORE_OK && got == 0;
450 cbm_store_node_scan_close(scan);
451 cbm_store_free_nodes(eager, n);
452 return same && seen == n ? n : -1;
453}
454
455/* Pages of 1, 3 and 64 rows end inside files, at file boundaries and inside
456 * the NULL file_path rows, which the eager all-nodes order puts first. The

Callers 1

test_store_nodes.cFile · 0.85

Calls 9

cbm_store_find_nodesFunction · 0.85
cbm_store_node_scan_openFunction · 0.85
cbm_store_node_scan_nextFunction · 0.85
scan_node_sameFunction · 0.85
cbm_node_free_fieldsFunction · 0.85
cbm_store_free_nodesFunction · 0.85

Tested by

no test coverage detected