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