MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / countOutgoingEdges

Method countOutgoingEdges

src/db/queries.ts:2886–2901  ·  view source on GitHub ↗

* Fan-out (total outgoing edge count) for MANY nodes in one query — the * mirror of countIncomingEdges. Ids with no outgoing edges are absent * from the map rather than present as 0.

(ids: readonly string[])

Source from the content-addressed store, hash-verified

2884 * from the map rather than present as 0.
2885 */
2886 countOutgoingEdges(ids: readonly string[]): Map<string, number> {
2887 const out = new Map<string, number>();
2888 if (ids.length === 0) return out;
2889 const unique = [...new Set(ids)];
2890 for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
2891 const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
2892 const placeholders = chunk.map(() => '?').join(',');
2893 const rows = this.db
2894 .prepare(
2895 `SELECT source, COUNT(*) AS count FROM edges WHERE source IN (${placeholders}) GROUP BY source`
2896 )
2897 .all(...chunk) as Array<{ source: string; count: number }>;
2898 for (const row of rows) out.set(row.source, row.count);
2899 }
2900 return out;
2901 }
2902
2903 /**
2904 * Symbols nothing in the index points at — the candidate set behind the dead

Callers 1

getFanOutMethod · 0.80

Calls 5

mapMethod · 0.80
allMethod · 0.65
prepareMethod · 0.65
joinMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected