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

Method runBatched

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

552 * decomposed greedily into the cached batch sizes. Preserves row order.
553 */
554 private runBatched(kind: string, head: string, tuple: string, rows: unknown[][]): void {
555 if (rows.length === 0) return;
556 let i = 0;
557 for (const size of QueryBuilder.BATCH_SIZES) {
558 while (rows.length - i >= size) {
559 const key = `${kind}:${size}`;
560 let stmt = this.batchStmts.get(key);
561 if (!stmt) {
562 stmt = this.db.prepare(head + new Array(size).fill(tuple).join(','));
563 this.batchStmts.set(key, stmt);
564 }
565 if (size === 1) {
566 stmt.run(...rows[i]!);
567 } else {
568 const params: unknown[] = [];
569 for (let r = 0; r < size; r++) {
570 const row = rows[i + r]!;
571 for (let c = 0; c < row.length; c++) params.push(row[c]);
572 }
573 stmt.run(...params);
574 }
575 i += size;
576 }
577 }
578 }
579
580 constructor(db: SqliteDatabase) {
581 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