(ids: readonly string[])
| 488 | } |
| 489 | |
| 490 | private getExistingNodeIds(ids: readonly string[]): Set<string> { |
| 491 | const out = new Set<string>(); |
| 492 | if (ids.length === 0) return out; |
| 493 | |
| 494 | const uniqueIds = [...new Set(ids)]; |
| 495 | for (let i = 0; i < uniqueIds.length; i += SQLITE_PARAM_CHUNK_SIZE) { |
| 496 | const chunk = uniqueIds.slice(i, i + SQLITE_PARAM_CHUNK_SIZE); |
| 497 | const placeholders = chunk.map(() => '?').join(','); |
| 498 | const rows = this.db |
| 499 | .prepare(`SELECT id FROM nodes WHERE id IN (${placeholders})`) |
| 500 | .all(...chunk) as { id: string }[]; |
| 501 | for (const row of rows) { |
| 502 | out.add(row.id); |
| 503 | } |
| 504 | } |
| 505 | |
| 506 | return out; |
| 507 | } |
| 508 | |
| 509 | /** |
| 510 | * Add a node to the cache, evicting oldest if needed |
no test coverage detected