From 837f3ba9e7ba6f8d4ff4f60890a56d4c3c7119e3 Mon Sep 17 00:00:00 2001 From: mdesalvo Date: Sun, 13 Oct 2019 18:57:45 +0200 Subject: [PATCH] Better management of values uniqueness --- RDFSharp/Query/Mirella/Algebra/RDFPatternGroup.cs | 10 +++++++--- RDFSharp/Query/Mirella/RDFQueryEngine.cs | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/RDFSharp/Query/Mirella/Algebra/RDFPatternGroup.cs b/RDFSharp/Query/Mirella/Algebra/RDFPatternGroup.cs index 1c4259e4..781ad4a6 100644 --- a/RDFSharp/Query/Mirella/Algebra/RDFPatternGroup.cs +++ b/RDFSharp/Query/Mirella/Algebra/RDFPatternGroup.cs @@ -189,8 +189,12 @@ public RDFPatternGroup AddPropertyPath(RDFPropertyPath propertyPath) public RDFPatternGroup AddValues(RDFValues values) { if (values != null) - this.GroupMembers.Add(values); - + { + if (!this.GetValues().Any(v => v.Equals(values))) + { + this.GroupMembers.Add(values); + } + } return this; } @@ -268,7 +272,7 @@ internal RDFPatternGroup AddInjectedValues(RDFValues values) clonedValues.IsEvaluable = values.IsEvaluable; clonedValues.IsInjected = true; - this.GroupMembers.Add(clonedValues); + this.AddValues(clonedValues); } return this; } diff --git a/RDFSharp/Query/Mirella/RDFQueryEngine.cs b/RDFSharp/Query/Mirella/RDFQueryEngine.cs index 727547be..72ecb715 100644 --- a/RDFSharp/Query/Mirella/RDFQueryEngine.cs +++ b/RDFSharp/Query/Mirella/RDFQueryEngine.cs @@ -605,7 +605,9 @@ internal void EvaluatePatternGroup(RDFQuery query, RDFPatternGroup patternGroup, QueryMemberTemporaryResultTables[patternGroup.QueryMemberID] = new List(); //Iterate the evaluable members of the pattern group - List evaluablePGMembers = patternGroup.GetEvaluablePatternGroupMembers().ToList(); + List evaluablePGMembers = patternGroup.GetEvaluablePatternGroupMembers() + .Distinct() + .ToList(); foreach (RDFPatternGroupMember evaluablePGMember in evaluablePGMembers) {