diff --git a/cpg-neo4j/src/main/kotlin/de/fraunhofer/aisec/cpg/v2/Persistence.kt b/cpg-neo4j/src/main/kotlin/de/fraunhofer/aisec/cpg/v2/Persistence.kt index 376ea5ea96..46929daa33 100644 --- a/cpg-neo4j/src/main/kotlin/de/fraunhofer/aisec/cpg/v2/Persistence.kt +++ b/cpg-neo4j/src/main/kotlin/de/fraunhofer/aisec/cpg/v2/Persistence.kt @@ -67,10 +67,6 @@ fun TranslationResult.persist() { val nodes = this@persist.nodes val edges = this@persist.allEdges>() - neo4jSession.executeWrite { tx -> - tx.run("CREATE INDEX IF NOT EXISTS FOR (n:Node) ON (n.id)").consume() - } - log.info("Persisting {} nodes", nodes.size) nodes.persist() @@ -101,6 +97,10 @@ private fun List.persist() { } private fun Collection>.persist() { + neo4jSession.executeWrite { tx -> + tx.run("CREATE INDEX IF NOT EXISTS FOR (n:Node) ON (n.id)").consume() + } + val groups = groupBy { it.label } groups.forEach { it.value.chunked(10000).forEach { chunk -> diff --git a/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg/v2/TestPersistence.kt b/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg/v2/TestPersistence.kt index 7685a0df95..9ec02f4896 100644 --- a/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg/v2/TestPersistence.kt +++ b/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg/v2/TestPersistence.kt @@ -25,11 +25,7 @@ */ package de.fraunhofer.aisec.cpg.v2 -import de.fraunhofer.aisec.cpg.frontends.python.PythonLanguage -import de.fraunhofer.aisec.cpg.helpers.Benchmark -import de.fraunhofer.aisec.cpg.test.analyze import de.fraunhofer.aisec.cpg_vis_neo4j.createTranslationResult -import java.nio.file.Path import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test @@ -42,28 +38,4 @@ class TestPersistence { neo4jSession.executeWrite { tx -> tx.run("MATCH (n) DETACH DELETE n").consume() } result.second.persist() } - - @Test - fun testPersistGlance() { - val topLevel = - Path.of("/Users/chr55316/Repositories/openstack-checker/targets/projects/glance") - val result = - analyze( - listOf( - topLevel.resolve("glance").toFile(), - ), - topLevel, - true - ) { - it.registerLanguage() - it.exclusionPatterns("tests") - it.useParallelFrontends(false) - it.failOnError(false) - } - - val bench = Benchmark(this.javaClass, "Persist") - neo4jSession.executeWrite { tx -> tx.run("MATCH (n) DETACH DELETE n").consume() } - result.persist() - bench.stop() - } }