* 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;
})
| 501 | * SELECT that insertEdges() pays is skipped here. |
| 502 | */ |
| 503 | storeFileBundle(bundle: { |
| 504 | nodes: Node[]; |
| 505 | edges: Edge[]; |
| 506 | refs: UnresolvedReference[]; |
| 507 | file: FileRecord; |
| 508 | }): void { |
| 509 | this.db.transaction(() => { |
| 510 | this.insertNodes(bundle.nodes); |
| 511 | if (bundle.edges.length > 0) { |
| 512 | const rows: unknown[][] = []; |
| 513 | for (const edge of bundle.edges) { |
| 514 | rows.push([ |
| 515 | edge.source, |
| 516 | edge.target, |
| 517 | edge.kind, |
| 518 | edge.metadata ? JSON.stringify(edge.metadata) : null, |
| 519 | edge.line ?? null, |
| 520 | edge.column ?? null, |
| 521 | edge.provenance ?? null, |
| 522 | ]); |
| 523 | } |
| 524 | this.runBatched( |
| 525 | 'insertEdges', |
| 526 | 'INSERT OR IGNORE INTO edges (source, target, kind, metadata, line, col, provenance) VALUES ', |
| 527 | '(?,?,?,?,?,?,?)', |
| 528 | rows |
| 529 | ); |
| 530 | } |
| 531 | if (bundle.refs.length > 0) this.insertUnresolvedRefsBatch(bundle.refs); |
| 532 | this.upsertFile(bundle.file); |
| 533 | })(); |
| 534 | } |
| 535 | |
| 536 | /** |
| 537 | * Collect (segment, name) rows for a name, honouring the same session-dedupe |
no test coverage detected