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

Function cbm_writer_finalize

internal/cbm/sqlite_writer.c:2326–2361  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2324}
2325
2326int cbm_writer_finalize(cbm_db_writer_t *w, const char *project, const char *root_path,
2327 const char *indexed_at, CBMDumpNode *nodes, int node_count,
2328 CBMDumpEdge *edges, int edge_count, CBMDumpVector *vectors,
2329 int vector_count, CBMDumpTokenVec *token_vecs, int token_vec_count) {
2330 if (!w) {
2331 return CBM_NOT_FOUND;
2332 }
2333 int err = w->err;
2334 uint32_t nodes_root = 0;
2335 if (err == 0) {
2336 if (w->node_rows_written == 0) {
2337 pb_free(&w->nodes_pb);
2338 nodes_root = write_table_btree(w->wc.fp, &w->wc.next_page, NULL, NULL, NULL, 0, false);
2339 } else {
2340 nodes_root = pb_finalize_table(&w->nodes_pb, &w->wc.next_page, w->last_node_rowid);
2341 }
2342 }
2343 w->wc.project = project;
2344 w->wc.root_path = root_path;
2345 w->wc.indexed_at = indexed_at;
2346 w->wc.nodes = nodes;
2347 w->wc.node_count = node_count;
2348 w->wc.edges = edges;
2349 w->wc.edge_count = edge_count;
2350 w->wc.vectors = vectors;
2351 w->wc.vector_count = vector_count;
2352 w->wc.token_vecs = token_vecs;
2353 w->wc.token_vec_count = token_vec_count;
2354
2355 write_db_ctx_t wc = w->wc; /* value copy survives free(w) */
2356 free(w);
2357 if (err != 0) {
2358 return discard_writer_output(&wc, err);
2359 }
2360 return write_db_after_nodes(&wc, nodes_root);
2361}
2362
2363int cbm_write_db(const char *path, const char *project, const char *root_path,
2364 const char *indexed_at, CBMDumpNode *nodes, int node_count, CBMDumpEdge *edges,

Callers 3

cbm_write_dbFunction · 0.85
cbm_gbuf_dump_to_sqliteFunction · 0.85

Calls 5

pb_freeFunction · 0.85
write_table_btreeFunction · 0.85
pb_finalize_tableFunction · 0.85
discard_writer_outputFunction · 0.85
write_db_after_nodesFunction · 0.85

Tested by

no test coverage detected