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

Method getExistingNodeIds

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

Source from the content-addressed store, hash-verified

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