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

Method insertNodes

src/db/queries.ts:879–945  ·  view source on GitHub ↗

* Insert multiple nodes in a transaction

(nodes: Node[])

Source from the content-addressed store, hash-verified

877 * Insert multiple nodes in a transaction
878 */
879 insertNodes(nodes: Node[]): void {
880 this.db.transaction(() => {
881 // Bulk path: same semantics as insertNode() per row (validation, cache
882 // invalidation, segment vocab), but bound as multi-row INSERTs — the
883 // per-.run() call overhead dominates the store phase on full indexes.
884 const rows: unknown[][] = [];
885 const segmentRows: unknown[][] = [];
886 const memberRows: unknown[][] = [];
887 for (const node of nodes) {
888 if (!node.id || !node.kind || !node.name || !node.filePath || !node.language) {
889 console.error('[CodeGraph] Skipping node with missing required fields:', {
890 id: node.id,
891 kind: node.kind,
892 name: node.name,
893 filePath: node.filePath,
894 language: node.language,
895 });
896 continue;
897 }
898 this.nodeCache.delete(node.id);
899 rows.push([
900 node.id,
901 node.kind,
902 node.name,
903 node.qualifiedName ?? node.name,
904 node.filePath,
905 node.language,
906 node.startLine ?? 0,
907 node.endLine ?? 0,
908 node.startColumn ?? 0,
909 node.endColumn ?? 0,
910 node.docstring ?? null,
911 node.signature ?? null,
912 node.visibility ?? null,
913 node.isExported ? 1 : 0,
914 node.isAsync ? 1 : 0,
915 node.isStatic ? 1 : 0,
916 node.isAbstract ? 1 : 0,
917 node.decorators ? JSON.stringify(node.decorators) : null,
918 node.typeParameters ? JSON.stringify(node.typeParameters) : null,
919 node.returnType ?? null,
920 node.updatedAt ?? Date.now(),
921 ]);
922 if (this.isSegmentableKind(node.kind)) this.collectNameSegmentRows(node.name, segmentRows);
923 if (node.objectMembers) memberRows.push([node.id, node.objectMembers.lines, node.objectMembers.names]);
924 }
925 this.runBatched(
926 'insertNodes',
927 `INSERT OR REPLACE INTO nodes (
928 id, kind, name, qualified_name, file_path, language,
929 start_line, end_line, start_column, end_column,
930 docstring, signature, visibility,
931 is_exported, is_async, is_static, is_abstract,
932 decorators, type_parameters, return_type, updated_at
933 ) VALUES `,
934 '(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
935 rows
936 );

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