* 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;
})
| 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 |
no test coverage detected