* 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;
})
| 965 | * SELECT that insertEdges() pays is skipped here. |
| 966 | */ |
| 967 | storeFileBundle(bundle: { |
| 968 | nodes: Node[]; |
| 969 | edges: Edge[]; |
| 970 | refs: UnresolvedReference[]; |
| 971 | file: FileRecord; |
| 972 | }): void { |
| 973 | this.db.transaction(() => { |
| 974 | this.insertNodes(bundle.nodes); |
| 975 | if (bundle.edges.length > 0) { |
| 976 | const rows: unknown[][] = []; |
| 977 | for (const edge of bundle.edges) { |
| 978 | rows.push([ |
| 979 | edge.source, |
| 980 | edge.target, |
| 981 | edge.kind, |
| 982 | edge.metadata ? JSON.stringify(edge.metadata) : null, |
| 983 | edge.line ?? null, |
| 984 | edge.column ?? null, |
| 985 | edge.provenance ?? null, |
| 986 | ]); |
| 987 | } |
| 988 | this.runBatched( |
| 989 | 'insertEdges', |
| 990 | 'INSERT OR IGNORE INTO edges (source, target, kind, metadata, line, col, provenance) VALUES ', |
| 991 | '(?,?,?,?,?,?,?)', |
| 992 | rows |
| 993 | ); |
| 994 | } |
| 995 | if (bundle.refs.length > 0) this.insertUnresolvedRefsBatch(bundle.refs); |
| 996 | this.upsertFile(bundle.file); |
| 997 | })(); |
| 998 | } |
| 999 | |
| 1000 | /** |
| 1001 | * Collect (segment, name) rows for a name, honouring the same session-dedupe |
no test coverage detected