* 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;
})
| 897 | * SELECT that insertEdges() pays is skipped here. |
| 898 | */ |
| 899 | storeFileBundle(bundle: { |
| 900 | nodes: Node[]; |
| 901 | edges: Edge[]; |
| 902 | refs: UnresolvedReference[]; |
| 903 | file: FileRecord; |
| 904 | }): void { |
| 905 | this.db.transaction(() => { |
| 906 | this.insertNodes(bundle.nodes); |
| 907 | if (bundle.edges.length > 0) { |
| 908 | const rows: unknown[][] = []; |
| 909 | for (const edge of bundle.edges) { |
| 910 | rows.push([ |
| 911 | edge.source, |
| 912 | edge.target, |
| 913 | edge.kind, |
| 914 | edge.metadata ? JSON.stringify(edge.metadata) : null, |
| 915 | edge.line ?? null, |
| 916 | edge.column ?? null, |
| 917 | edge.provenance ?? null, |
| 918 | ]); |
| 919 | } |
| 920 | this.runBatched( |
| 921 | 'insertEdges', |
| 922 | 'INSERT OR IGNORE INTO edges (source, target, kind, metadata, line, col, provenance) VALUES ', |
| 923 | '(?,?,?,?,?,?,?)', |
| 924 | rows |
| 925 | ); |
| 926 | } |
| 927 | if (bundle.refs.length > 0) this.insertUnresolvedRefsBatch(bundle.refs); |
| 928 | this.upsertFile(bundle.file); |
| 929 | })(); |
| 930 | } |
| 931 | |
| 932 | /** |
| 933 | * Collect (segment, name) rows for a name, honouring the same session-dedupe |
no test coverage detected