Skip to content

Commit

Permalink
Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
oxisto committed Dec 10, 2024
1 parent 0ebe7a4 commit 0097423
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ fun TranslationResult.persist() {
val nodes = this@persist.nodes
val edges = this@persist.allEdges<Edge<*>>()

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()

Expand Down Expand Up @@ -101,6 +97,10 @@ private fun List<Node>.persist() {
}

private fun Collection<Edge<*>>.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 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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<PythonLanguage>()
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()
}
}

0 comments on commit 0097423

Please sign in to comment.