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

Method countOutgoingEdges

src/db/queries.ts:2920–2935  ·  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

2918 * from the map rather than present as 0.
2919 */
2920 countOutgoingEdges(ids: readonly string[]): Map<string, number> {
2921 const out = new Map<string, number>();
2922 if (ids.length === 0) return out;
2923 const unique = [...new Set(ids)];
2924 for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
2925 const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
2926 const placeholders = chunk.map(() => '?').join(',');
2927 const rows = this.db
2928 .prepare(
2929 `SELECT source, COUNT(*) AS count FROM edges WHERE source IN (${placeholders}) GROUP BY source`
2930 )
2931 .all(...chunk) as Array<{ source: string; count: number }>;
2932 for (const row of rows) out.set(row.source, row.count);
2933 }
2934 return out;
2935 }
2936
2937 /**
2938 * 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