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

Method runBatched

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

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