Skip to content

Commit 690077a

Browse files
committed
Improve git file to code file matching performance
1 parent 0d9a70b commit 690077a

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

cypher/GitLog/Add_RESOLVES_TO_relationships_to_git_files_for_Java.cypher

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// The differences are subtle but need to be thought through and tested carefully.
77
// Having separate files makes it obvious that there needs to be one for every new source code language.
88

9-
MATCH (code_file:!Git&File)
9+
MATCH (code_file:!Git&File&!Directory)
1010
WHERE code_file.fileName IS NOT NULL
1111
// Use only original code files, no resolved duplicates
1212
AND NOT EXISTS { (code_file)-[:RESOLVES_TO]->(other_file:File&!Git) }
@@ -17,8 +17,10 @@ MATCH (git_file:Git&File)
1717
,git_file
1818
,coalesce(git_file.fileName, git_file.relativePath) AS gitFileName
1919
WHERE gitFileName ENDS WITH codeFileName
20-
MERGE (git_file)-[:RESOLVES_TO]->(code_file)
21-
SET git_file.resolved = true
20+
CALL { WITH git_file, code_file
21+
MERGE (git_file)-[:RESOLVES_TO]->(code_file)
22+
ON CREATE SET git_file.resolved = true
23+
} IN TRANSACTIONS
2224
RETURN count(DISTINCT codeFileName) AS numberOfCodeFiles
2325
,collect(DISTINCT codeFileName + ' <-> ' + gitFileName + '\n')[0..4] AS examples
2426
// RETURN codeFileName, gitFileName

cypher/GitLog/Add_RESOLVES_TO_relationships_to_git_files_for_Typescript.cypher

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
// The differences are subtle but need to be thought through and tested carefully.
44
// Having separate files makes it obvious that there needs to be one for every new source code language.
55

6-
MATCH (code_file:!Git&File)
6+
MATCH (code_file:!Git&File&!Directory&!Scan)
77
WHERE (code_file.absoluteFileName IS NOT NULL OR code_file.fileName IS NOT NULL)
8-
// Use only original code files, no resolved duplicates
9-
AND NOT EXISTS { (code_file)-[:RESOLVES_TO]->(other_file:File&!Git) }
108
WITH code_file
119
,coalesce(code_file.absoluteFileName, code_file.fileName) AS codeFileName
1210
MATCH (git_file:Git&File)
11+
WHERE codeFileName ENDS WITH git_file.fileName
12+
OR codeFileName ENDS WITH git_file.relativePath
1313
// Use repository if available to overcome ambiguity in multi source analysis
1414
OPTIONAL MATCH (git_repository:Git&Repository)-[:HAS_FILE]->(git_file)
1515
WITH *
@@ -19,8 +19,10 @@ OPTIONAL MATCH (git_repository:Git&Repository)-[:HAS_FILE]->(git_file)
1919
,coalesce(git_repository.name + '/', '') + git_file.relativePath
2020
) AS gitFileName
2121
WHERE codeFileName ENDS WITH gitFileName
22-
MERGE (git_file)-[:RESOLVES_TO]->(code_file)
23-
SET git_file.resolved = true
22+
CALL { WITH git_file, code_file
23+
MERGE (git_file)-[:RESOLVES_TO]->(code_file)
24+
ON CREATE SET git_file.resolved = true
25+
} IN TRANSACTIONS
2426
RETURN count(DISTINCT codeFileName) AS numberOfCodeFiles
2527
,collect(DISTINCT codeFileName + ' <-> ' + gitFileName + '\n')[0..4] AS examples
2628
// RETURN codeFileName, gitFileName

0 commit comments

Comments
 (0)