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

Method runBatched

src/db/queries.ts:336–360  ·  view source on GitHub ↗

* Run `rows` through a multi-row `INSERT` built as `head + (tuple,)*n`, * decomposed greedily into the cached batch sizes. Preserves row order.

(kind: string, head: string, tuple: string, rows: unknown[][])

Source from the content-addressed store, hash-verified

334 * decomposed greedily into the cached batch sizes. Preserves row order.
335 */
336 private runBatched(kind: string, head: string, tuple: string, rows: unknown[][]): void {
337 if (rows.length === 0) return;
338 let i = 0;
339 for (const size of QueryBuilder.BATCH_SIZES) {
340 while (rows.length - i >= size) {
341 const key = `${kind}:${size}`;
342 let stmt = this.batchStmts.get(key);
343 if (!stmt) {
344 stmt = this.db.prepare(head + new Array(size).fill(tuple).join(','));
345 this.batchStmts.set(key, stmt);
346 }
347 if (size === 1) {
348 stmt.run(...rows[i]!);
349 } else {
350 const params: unknown[] = [];
351 for (let r = 0; r < size; r++) {
352 const row = rows[i + r]!;
353 for (let c = 0; c < row.length; c++) params.push(row[c]);
354 }
355 stmt.run(...params);
356 }
357 i += size;
358 }
359 }
360 }
361
362 constructor(db: SqliteDatabase) {
363 this.db = db;

Callers 6

insertNameSegmentsMethod · 0.95
insertNodesMethod · 0.95
storeFileBundleMethod · 0.95
insertEdgesMethod · 0.95

Calls 7

fillMethod · 0.80
pushMethod · 0.80
getMethod · 0.65
prepareMethod · 0.65
runMethod · 0.65
joinMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected