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

Method storeFileBundle

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

610 * SELECT that insertEdges() pays is skipped here.
611 */
612 storeFileBundle(bundle: {
613 nodes: Node[];
614 edges: Edge[];
615 refs: UnresolvedReference[];
616 file: FileRecord;
617 }): void {
618 this.db.transaction(() => {
619 this.insertNodes(bundle.nodes);
620 if (bundle.edges.length > 0) {
621 const rows: unknown[][] = [];
622 for (const edge of bundle.edges) {
623 rows.push([
624 edge.source,
625 edge.target,
626 edge.kind,
627 edge.metadata ? JSON.stringify(edge.metadata) : null,
628 edge.line ?? null,
629 edge.column ?? null,
630 edge.provenance ?? null,
631 ]);
632 }
633 this.runBatched(
634 'insertEdges',
635 'INSERT OR IGNORE INTO edges (source, target, kind, metadata, line, col, provenance) VALUES ',
636 '(?,?,?,?,?,?,?)',
637 rows
638 );
639 }
640 if (bundle.refs.length > 0) this.insertUnresolvedRefsBatch(bundle.refs);
641 this.upsertFile(bundle.file);
642 })();
643 }
644
645 /**
646 * 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