Skip to content
Snippets Groups Projects
Commit 72345c98 authored by Sirieam Marie Hunke's avatar Sirieam Marie Hunke
Browse files

Merge branch 'Hotfix/2615-graphDeployerLag' into 'master'

Fix: Optimize graph triple comparison using projection method

See merge request !14
parents a4285bf1 88e80f58
No related branches found
No related tags found
2 merge requests!15Hotfix#2615,!14Fix: Optimize graph triple comparison using projection method
......@@ -114,11 +114,12 @@ public class Program
var currentGraph = Helpers.WrapRequest(() => _rdfStoreConnector.GetGraph(graphName));
// Project the triples for easier comparison
var projectedGraph = graph.Triples.Select(ProjectTriple).ToList();
var projectedCurrentGraph = currentGraph.Triples.Select(ProjectTriple).ToList();
var graphWasChanged = graph.Triples.Count != currentGraph.Triples.Count
|| graph.Triples.Any((triple) => !currentGraph.Triples.Any((currentTriple) =>
(triple.Subject.Equals(currentTriple.Subject) || (triple.Subject.NodeType == NodeType.Blank && currentTriple.Subject.NodeType == NodeType.Blank)
&& triple.Predicate.Equals(currentTriple.Predicate)
&& triple.Object.Equals(currentTriple.Object) || (triple.Object.NodeType == NodeType.Blank && currentTriple.Object.NodeType == NodeType.Blank))));
|| projectedGraph.Except(projectedCurrentGraph).Any();
if (graphWasChanged)
{
......@@ -141,9 +142,9 @@ public class Program
else
{
_logger.LogInformation("Skipping {graphName}", graphName);
}
}
queries.Add($"rdf_loader_run ();");
queries.Add($"DELETE from DB.DBA.load_list where 1=1;");
......@@ -233,4 +234,11 @@ public class Program
LogInnerException(ex.InnerException);
}
}
private static string ProjectTriple(Triple triple)
{
return $"{(triple.Subject.NodeType == NodeType.Blank ? "BLANK" : triple.Subject.ToString())}," +
$"{triple.Predicate.ToString()}," +
$"{(triple.Object.NodeType == NodeType.Blank ? "BLANK" : triple.Object.ToString())}";
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment