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

Method insertNodes

src/db/queries.ts:536–599  ·  view source on GitHub ↗

* Insert multiple nodes in a transaction

(nodes: Node[])

Source from the content-addressed store, hash-verified

534 * Insert multiple nodes in a transaction
535 */
536 insertNodes(nodes: Node[]): void {
537 this.db.transaction(() => {
538 // Bulk path: same semantics as insertNode() per row (validation, cache
539 // invalidation, segment vocab), but bound as multi-row INSERTs — the
540 // per-.run() call overhead dominates the store phase on full indexes.
541 const rows: unknown[][] = [];
542 const segmentRows: unknown[][] = [];
543 for (const node of nodes) {
544 if (!node.id || !node.kind || !node.name || !node.filePath || !node.language) {
545 console.error('[CodeGraph] Skipping node with missing required fields:', {
546 id: node.id,
547 kind: node.kind,
548 name: node.name,
549 filePath: node.filePath,
550 language: node.language,
551 });
552 continue;
553 }
554 this.nodeCache.delete(node.id);
555 rows.push([
556 node.id,
557 node.kind,
558 node.name,
559 node.qualifiedName ?? node.name,
560 node.filePath,
561 node.language,
562 node.startLine ?? 0,
563 node.endLine ?? 0,
564 node.startColumn ?? 0,
565 node.endColumn ?? 0,
566 node.docstring ?? null,
567 node.signature ?? null,
568 node.visibility ?? null,
569 node.isExported ? 1 : 0,
570 node.isAsync ? 1 : 0,
571 node.isStatic ? 1 : 0,
572 node.isAbstract ? 1 : 0,
573 node.decorators ? JSON.stringify(node.decorators) : null,
574 node.typeParameters ? JSON.stringify(node.typeParameters) : null,
575 node.returnType ?? null,
576 node.updatedAt ?? Date.now(),
577 ]);
578 if (this.isSegmentableKind(node.kind)) this.collectNameSegmentRows(node.name, segmentRows);
579 }
580 this.runBatched(
581 'insertNodes',
582 `INSERT OR REPLACE INTO nodes (
583 id, kind, name, qualified_name, file_path, language,
584 start_line, end_line, start_column, end_column,
585 docstring, signature, visibility,
586 is_exported, is_async, is_static, is_abstract,
587 decorators, type_parameters, return_type, updated_at
588 ) VALUES `,
589 '(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
590 rows
591 );
592 this.runBatched(
593 'insertNameSegments',

Callers 5

storeFileBundleMethod · 0.95
storeExtractionResultMethod · 0.80
db-perf.test.tsFile · 0.80

Calls 7

isSegmentableKindMethod · 0.95
runBatchedMethod · 0.95
pushMethod · 0.80
transactionMethod · 0.65
errorMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected