* 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
()
| 342 | * stays inside the window. |
| 343 | */ |
| 344 | async endBulkEdgeLoad(): Promise<void> { |
| 345 | const schemaPath = path.join(__dirname, 'schema.sql'); |
| 346 | const schema = fs.readFileSync(schemaPath, 'utf-8'); |
| 347 | for (const idx of DatabaseConnection.BULK_EDGE_INDEX_NAMES) { |
| 348 | const m = schema.match(new RegExp(`CREATE INDEX IF NOT EXISTS ${idx}\\b[^;]*;`)); |
| 349 | if (!m) throw new Error(`schema.sql: edge index ${idx} not found for bulk-load recreation`); |
| 350 | this.db.exec(m[0]); |
| 351 | await new Promise((resolve) => setImmediate(resolve)); |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | /** Recreate the FTS triggers + rebuild if a bulk-load window never closed. */ |
| 356 | private healBulkNodeLoad(): void { |
no test coverage detected