* Leave bulk-edge-load mode: recreate the dropped indexes in one pass each * over the (now fully loaded) edges table — far cheaper than maintaining * them per-insert. DDL is extracted from schema.sql so it cannot drift. * * Async with a yield BETWEEN the four CREATE INDEX statements: eac
(options: { deferSynthesisSite?: boolean } = {})
| 437 | * stays inside the window. |
| 438 | */ |
| 439 | async endBulkEdgeLoad(options: { deferSynthesisSite?: boolean } = {}): Promise<void> { |
| 440 | const schemaPath = path.join(__dirname, 'schema.sql'); |
| 441 | const schema = fs.readFileSync(schemaPath, 'utf-8'); |
| 442 | for (const idx of DatabaseConnection.BULK_EDGE_INDEX_NAMES) { |
| 443 | if (options.deferSynthesisSite && idx === DatabaseConnection.SYNTHESIS_SITE_INDEX) continue; |
| 444 | const m = schema.match(new RegExp(`CREATE INDEX IF NOT EXISTS ${idx}\\b[^;]*;`)); |
| 445 | if (!m) throw new Error(`schema.sql: edge index ${idx} not found for bulk-load recreation`); |
| 446 | this.db.exec(m[0]); |
| 447 | await new Promise((resolve) => setImmediate(resolve)); |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | /** |
| 452 | * The sync-only synthesis-site index (#1988), which endBulkEdgeLoad can |