* Outgoing edges for MANY source nodes in one query. * * The batch form of getOutgoingEdges. Building a nested outline needs * the `contains` edges of every container in a file at once; doing that one * source at a time is a query per symbol on files that have hundreds.
(sourceIds: readonly string[], kinds?: EdgeKind[])
| 2207 | * source at a time is a query per symbol on files that have hundreds. |
| 2208 | */ |
| 2209 | getOutgoingEdgesFrom(sourceIds: readonly string[], kinds?: EdgeKind[]): Edge[] { |
| 2210 | if (sourceIds.length === 0) return []; |
| 2211 | const unique = [...new Set(sourceIds)]; |
| 2212 | const out: Edge[] = []; |
| 2213 | for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) { |
| 2214 | const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE); |
| 2215 | const placeholders = chunk.map(() => '?').join(','); |
| 2216 | let sql = `SELECT * FROM edges WHERE source IN (${placeholders})`; |
| 2217 | const params: string[] = [...chunk]; |
| 2218 | if (kinds && kinds.length > 0) { |
| 2219 | sql += ` AND kind IN (${kinds.map(() => '?').join(',')})`; |
| 2220 | params.push(...kinds); |
| 2221 | } |
| 2222 | const rows = this.db.prepare(sql).all(...params) as EdgeRow[]; |
| 2223 | for (const row of rows) out.push(rowToEdge(row)); |
| 2224 | } |
| 2225 | return out; |
| 2226 | } |
| 2227 | |
| 2228 | /** |
| 2229 | * Fan-in (total incoming edge count) for MANY nodes in one query. |
no test coverage detected