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

Method getExistingNodeIds

src/db/queries.ts:1247–1271  ·  view source on GitHub ↗
(ids: readonly string[])

Source from the content-addressed store, hash-verified

1245 }
1246
1247 private getExistingNodeIds(ids: readonly string[]): Set<string> {
1248 const out = new Set<string>();
1249 if (ids.length === 0) return out;
1250
1251 const uniqueIds = [...new Set(ids)];
1252 for (let i = 0; i < uniqueIds.length; i += SQLITE_PARAM_CHUNK_SIZE) {
1253 const chunk = uniqueIds.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
1254 // Every edge insert checks its endpoints here, a chunk at a time: the
1255 // full-size statement is prepared once, the final partial chunk ad hoc.
1256 let stmt: SqliteStatement;
1257 if (chunk.length === SQLITE_PARAM_CHUNK_SIZE) {
1258 stmt = this.stmts.existingNodeIdsFull ??= this.db.prepare(
1259 `SELECT id FROM nodes WHERE id IN (${new Array(SQLITE_PARAM_CHUNK_SIZE).fill('?').join(',')})`
1260 );
1261 } else {
1262 stmt = this.db.prepare(`SELECT id FROM nodes WHERE id IN (${chunk.map(() => '?').join(',')})`);
1263 }
1264 const rows = stmt.all(...chunk) as { id: string }[];
1265 for (const row of rows) {
1266 out.add(row.id);
1267 }
1268 }
1269
1270 return out;
1271 }
1272
1273 /**
1274 * Add a node to the cache, evicting oldest if needed

Callers 1

insertEdgesMethod · 0.95

Calls 6

fillMethod · 0.80
mapMethod · 0.80
prepareMethod · 0.65
allMethod · 0.65
joinMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected