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

Method insertNodes

src/db/queries.ts:814–877  ·  view source on GitHub ↗

* Insert multiple nodes in a transaction

(nodes: Node[])

Source from the content-addressed store, hash-verified

812 * Insert multiple nodes in a transaction
813 */
814 insertNodes(nodes: Node[]): void {
815 this.db.transaction(() => {
816 // Bulk path: same semantics as insertNode() per row (validation, cache
817 // invalidation, segment vocab), but bound as multi-row INSERTs — the
818 // per-.run() call overhead dominates the store phase on full indexes.
819 const rows: unknown[][] = [];
820 const segmentRows: unknown[][] = [];
821 for (const node of nodes) {
822 if (!node.id || !node.kind || !node.name || !node.filePath || !node.language) {
823 console.error('[CodeGraph] Skipping node with missing required fields:', {
824 id: node.id,
825 kind: node.kind,
826 name: node.name,
827 filePath: node.filePath,
828 language: node.language,
829 });
830 continue;
831 }
832 this.nodeCache.delete(node.id);
833 rows.push([
834 node.id,
835 node.kind,
836 node.name,
837 node.qualifiedName ?? node.name,
838 node.filePath,
839 node.language,
840 node.startLine ?? 0,
841 node.endLine ?? 0,
842 node.startColumn ?? 0,
843 node.endColumn ?? 0,
844 node.docstring ?? null,
845 node.signature ?? null,
846 node.visibility ?? null,
847 node.isExported ? 1 : 0,
848 node.isAsync ? 1 : 0,
849 node.isStatic ? 1 : 0,
850 node.isAbstract ? 1 : 0,
851 node.decorators ? JSON.stringify(node.decorators) : null,
852 node.typeParameters ? JSON.stringify(node.typeParameters) : null,
853 node.returnType ?? null,
854 node.updatedAt ?? Date.now(),
855 ]);
856 if (this.isSegmentableKind(node.kind)) this.collectNameSegmentRows(node.name, segmentRows);
857 }
858 this.runBatched(
859 'insertNodes',
860 `INSERT OR REPLACE INTO nodes (
861 id, kind, name, qualified_name, file_path, language,
862 start_line, end_line, start_column, end_column,
863 docstring, signature, visibility,
864 is_exported, is_async, is_static, is_abstract,
865 decorators, type_parameters, return_type, updated_at
866 ) VALUES `,
867 '(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
868 rows
869 );
870 this.runBatched(
871 'insertNameSegments',

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