Count missed edges
@@ -3,6 +3,7 @@ package eu.fasten.core.merge;
import ch.qos.logback.classic.Level;
import eu.fasten.core.data.DirectedGraph;
import eu.fasten.core.data.ExtendedRevisionCallGraph;
+import eu.fasten.core.data.FastenURI;
import eu.fasten.core.data.graphdb.RocksDao;
import eu.fasten.core.data.metadatadb.codegen.tables.Callables;
import eu.fasten.core.dbconnectors.PostgresConnector;
@@ -86,29 +87,26 @@ public class Benchmark implements Runnable {
var localResolvedGraph = ERCGToMap(callgraph);
var databaseResolvedGraph = directedGraphToMap(directedGraph);
- var missedEdges = new HashMap<String, Set<String>>();
- for (var arc : localResolvedGraph.entrySet()) {
- if (!databaseResolvedGraph.containsKey(arc.getKey())) {
- for (var target : arc.getValue()) {
- missedEdges.merge(arc.getKey(), new HashSet<>(Collections.singleton(target)), (old, neu) -> {
- old.addAll(neu);
- return old;
- });
- }
- } else {
- for (var target : arc.getValue()) {
- if (!databaseResolvedGraph.get(arc.getKey()).contains(target)) {
- missedEdges.merge(arc.getKey(), new HashSet<>(Collections.singleton(target)), (old, neu) -> {
- old.addAll(neu);
- return old;
- });
- }
+ var missedEdges = getMissedEdges(localResolvedGraph, databaseResolvedGraph);
+ missedEdges.putAll(getMissedEdges(databaseResolvedGraph, localResolvedGraph));
+
+ var count = 0;
+ for (var edge : missedEdges.entrySet()) {
+ count += edge.getValue().size();
+ for (var target : edge.getValue()) {
+ System.out.println(FastenURI.create(target));
}
}
+
+ logger.info("Difference between graphs is {} edges", count);
+ System.out.println("==========================");
}
- for (var arc : databaseResolvedGraph.entrySet()) {
- if (!localResolvedGraph.containsKey(arc.getKey())) {
+ private Map<String, Set<String>> getMissedEdges(final Map<String, Set<String>> referenceGraph,
+ final Map<String, Set<String>> callgraph) {
+ var missedEdges = new HashMap<String, Set<String>>();
+ for (var arc : referenceGraph.entrySet()) {
+ if (!callgraph.containsKey(arc.getKey())) {
for (var target : arc.getValue()) {
missedEdges.merge(arc.getKey(), new HashSet<>(Collections.singleton(target)), (old, neu) -> {
old.addAll(neu);
@@ -117,7 +115,7 @@ public class Benchmark implements Runnable {
}
} else {
for (var target : arc.getValue()) {
- if (!localResolvedGraph.get(arc.getKey()).contains(target)) {
+ if (!callgraph.get(arc.getKey()).contains(target)) {
missedEdges.merge(arc.getKey(), new HashSet<>(Collections.singleton(target)), (old, neu) -> {
old.addAll(neu);
return old;
@@ -126,8 +124,7 @@ public class Benchmark implements Runnable {
}
}
}
-
- System.out.println("==========================");
+ return missedEdges;
}
private ExtendedRevisionCallGraph getLocalCallGraph() {
