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

Method storeFileBundle

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

545 * SELECT that insertEdges() pays is skipped here.
546 */
547 storeFileBundle(bundle: {
548 nodes: Node[];
549 edges: Edge[];
550 refs: UnresolvedReference[];
551 file: FileRecord;
552 }): void {
553 this.db.transaction(() => {
554 this.insertNodes(bundle.nodes);
555 if (bundle.edges.length > 0) {
556 const rows: unknown[][] = [];
557 for (const edge of bundle.edges) {
558 rows.push([
559 edge.source,
560 edge.target,
561 edge.kind,
562 edge.metadata ? JSON.stringify(edge.metadata) : null,
563 edge.line ?? null,
564 edge.column ?? null,
565 edge.provenance ?? null,
566 ]);
567 }
568 this.runBatched(
569 'insertEdges',
570 'INSERT OR IGNORE INTO edges (source, target, kind, metadata, line, col, provenance) VALUES ',
571 '(?,?,?,?,?,?,?)',
572 rows
573 );
574 }
575 if (bundle.refs.length > 0) this.insertUnresolvedRefsBatch(bundle.refs);
576 this.upsertFile(bundle.file);
577 })();
578 }
579
580 /**
581 * Collect (segment, name) rows for a name, honouring the same session-dedupe

Callers 2

storeExtractionResultMethod · 0.80
store-worker.tsFile · 0.80

Calls 5

insertNodesMethod · 0.95
runBatchedMethod · 0.95
upsertFileMethod · 0.95
transactionMethod · 0.65

Tested by

no test coverage detected