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