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

Method storeFileBundle

src/db/queries.ts:899–930  ·  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

897 * SELECT that insertEdges() pays is skipped here.
898 */
899 storeFileBundle(bundle: {
900 nodes: Node[];
901 edges: Edge[];
902 refs: UnresolvedReference[];
903 file: FileRecord;
904 }): void {
905 this.db.transaction(() => {
906 this.insertNodes(bundle.nodes);
907 if (bundle.edges.length > 0) {
908 const rows: unknown[][] = [];
909 for (const edge of bundle.edges) {
910 rows.push([
911 edge.source,
912 edge.target,
913 edge.kind,
914 edge.metadata ? JSON.stringify(edge.metadata) : null,
915 edge.line ?? null,
916 edge.column ?? null,
917 edge.provenance ?? null,
918 ]);
919 }
920 this.runBatched(
921 'insertEdges',
922 'INSERT OR IGNORE INTO edges (source, target, kind, metadata, line, col, provenance) VALUES ',
923 '(?,?,?,?,?,?,?)',
924 rows
925 );
926 }
927 if (bundle.refs.length > 0) this.insertUnresolvedRefsBatch(bundle.refs);
928 this.upsertFile(bundle.file);
929 })();
930 }
931
932 /**
933 * 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