MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / storeFileBundle

Method storeFileBundle

src/db/queries.ts:967–998  ·  view source on GitHub ↗

* Store one file's whole extraction bundle — nodes, edges, unresolved refs, * and the file record — in a SINGLE transaction. The bulk-index path calls * this once per file instead of opening one transaction per table (#1015 * file-order commit discipline is unchanged: callers still invoke i

(bundle: {
    nodes: Node[];
    edges: Edge[];
    refs: UnresolvedReference[];
    file: FileRecord;
  })

Source from the content-addressed store, hash-verified

965 * SELECT that insertEdges() pays is skipped here.
966 */
967 storeFileBundle(bundle: {
968 nodes: Node[];
969 edges: Edge[];
970 refs: UnresolvedReference[];
971 file: FileRecord;
972 }): void {
973 this.db.transaction(() => {
974 this.insertNodes(bundle.nodes);
975 if (bundle.edges.length > 0) {
976 const rows: unknown[][] = [];
977 for (const edge of bundle.edges) {
978 rows.push([
979 edge.source,
980 edge.target,
981 edge.kind,
982 edge.metadata ? JSON.stringify(edge.metadata) : null,
983 edge.line ?? null,
984 edge.column ?? null,
985 edge.provenance ?? null,
986 ]);
987 }
988 this.runBatched(
989 'insertEdges',
990 'INSERT OR IGNORE INTO edges (source, target, kind, metadata, line, col, provenance) VALUES ',
991 '(?,?,?,?,?,?,?)',
992 rows
993 );
994 }
995 if (bundle.refs.length > 0) this.insertUnresolvedRefsBatch(bundle.refs);
996 this.upsertFile(bundle.file);
997 })();
998 }
999
1000 /**
1001 * Collect (segment, name) rows for a name, honouring the same session-dedupe

Callers 2

storeExtractionResultMethod · 0.80
store-worker.tsFile · 0.80

Calls 6

insertNodesMethod · 0.95
runBatchedMethod · 0.95
upsertFileMethod · 0.95
pushMethod · 0.80
transactionMethod · 0.65

Tested by

no test coverage detected