/// <summary> /// Processes a Unknown Operator /// </summary> /// <param name="algebra">Unknown Operator</param> /// <param name="context">SPARQL Evaluation Context</param> public virtual BaseMultiset ProcessUnknownOperator(ISparqlAlgebra algebra, SparqlEvaluationContext context) { if (context == null) { context = this.GetContext(); } return(algebra.Evaluate(context)); }
/// <summary> /// Evalutes an Algebra Operator in this Context using the current Query Processor (if any) or the default <see cref="ISparqlAlgebra.Evaluate">Evaluate()</see> method. /// </summary> /// <param name="algebra">Algebra.</param> /// <returns></returns> public BaseMultiset Evaluate(ISparqlAlgebra algebra) { if (_processor == null) { return(algebra.Evaluate(this)); } else { return(_processor.ProcessAlgebra(algebra, this)); } }
public void SparqlPropertyPathEvaluationInverseNegatedPropertySet() { EnsureTestData(); NegatedSet path = new NegatedSet(Enumerable.Empty <Property>(), new Property[] { new Property(this._factory.CreateUriNode(new Uri(RdfSpecsHelper.RdfType))) }); ISparqlAlgebra algebra = this.GetAlgebra(path); SparqlEvaluationContext context = new SparqlEvaluationContext(null, this._data); BaseMultiset results = algebra.Evaluate(context); TestTools.ShowMultiset(results); Assert.IsFalse(results.IsEmpty, "Results should not be empty"); }
public void SparqlPropertyPathEvaluationZeroLengthWithTermStart() { EnsureTestData(); FixedCardinality path = new FixedCardinality(new Property(this._factory.CreateUriNode(new Uri(RdfSpecsHelper.RdfType))), 0); ISparqlAlgebra algebra = this.GetAlgebra(path, new Graph().CreateUriNode(UriFactory.Create(ConfigurationLoader.ClassHttpHandler)), null); SparqlEvaluationContext context = new SparqlEvaluationContext(null, this._data); BaseMultiset results = algebra.Evaluate(context); TestTools.ShowMultiset(results); Assert.IsFalse(results.IsEmpty, "Results should not be empty"); }
public void SparqlPropertyPathEvaluationZeroLength() { EnsureTestData(); FixedCardinality path = new FixedCardinality(new Property(this._factory.CreateUriNode(new Uri(RdfSpecsHelper.RdfType))), 0); ISparqlAlgebra algebra = this.GetAlgebra(path); SparqlEvaluationContext context = new SparqlEvaluationContext(null, this._data); BaseMultiset results = algebra.Evaluate(context); TestTools.ShowMultiset(results); Assert.False(results.IsEmpty, "Results should not be empty"); }
public void SparqlPropertyPathEvaluationSequencedAlternatives() { EnsureTestData(); INode a = this._factory.CreateUriNode(new Uri(RdfSpecsHelper.RdfType)); INode b = this._factory.CreateUriNode(new Uri(NamespaceMapper.RDFS + "range")); SequencePath path = new SequencePath(new AlternativePath(new Property(a), new Property(b)), new AlternativePath(new Property(a), new Property(a))); ISparqlAlgebra algebra = this.GetAlgebraUntransformed(path); SparqlEvaluationContext context = new SparqlEvaluationContext(null, this._data); BaseMultiset results = algebra.Evaluate(context); TestTools.ShowMultiset(results); Assert.IsFalse(results.IsEmpty, "Results should not be empty"); }
public void SparqlPropertyPathEvaluationZeroLengthWithTermEnd() { EnsureTestData(); FixedCardinality path = new FixedCardinality(new Property(this._factory.CreateUriNode(new Uri(RdfSpecsHelper.RdfType))), 0); INode rdfsClass = this._factory.CreateUriNode(new Uri(NamespaceMapper.RDFS + "Class")); ISparqlAlgebra algebra = this.GetAlgebra(path, null, rdfsClass); SparqlEvaluationContext context = new SparqlEvaluationContext(null, this._data); BaseMultiset results = algebra.Evaluate(context); TestTools.ShowMultiset(results); Assert.IsFalse(results.IsEmpty, "Results should not be empty"); Assert.AreEqual(1, results.Count, "Expected 1 Result"); Assert.AreEqual(rdfsClass, results[1]["x"], "Expected 1 Result set to rdfs:Class"); }
public void SparqlPropertyPathEvaluationZeroOrMorePath() { TripleStore store = new TripleStore(); Graph g = new Graph(); g.LoadFromFile("InferenceTest.ttl"); store.Add(g); InMemoryDataset dataset = new InMemoryDataset(store, g.BaseUri); ZeroOrMore path = new ZeroOrMore(new Property(this._factory.CreateUriNode(new Uri(NamespaceMapper.RDFS + "subClassOf")))); ISparqlAlgebra algebra = this.GetAlgebra(path); BaseMultiset results = algebra.Evaluate(new SparqlEvaluationContext(null, dataset)); TestTools.ShowMultiset(results); Assert.IsFalse(results.IsEmpty, "Results should not be empty"); }
public void SparqlPropertyPathEvaluationZeroOrMorePathForward() { TripleStore store = new TripleStore(); Graph g = new Graph(); g.LoadFromFile("resources\\InferenceTest.ttl"); store.Add(g); InMemoryDataset dataset = new InMemoryDataset(store); ZeroOrMore path = new ZeroOrMore(new Property(this._factory.CreateUriNode(new Uri(NamespaceMapper.RDFS + "subClassOf")))); INode sportsCar = this._factory.CreateUriNode(new Uri("http://example.org/vehicles/SportsCar")); ISparqlAlgebra algebra = this.GetAlgebra(path, sportsCar, null); BaseMultiset results = algebra.Evaluate(new SparqlEvaluationContext(null, dataset)); TestTools.ShowMultiset(results); Assert.False(results.IsEmpty, "Results should not be empty"); }
/// <summary> /// Evalutes an Algebra Operator in this Context using the current Query Processor (if any) or the default <see cref="ISparqlAlgebra.Evaluate">Evaluate()</see> method /// </summary> /// <param name="algebra">Algebra</param> /// <returns></returns> public BaseMultiset Evaluate(ISparqlAlgebra algebra) { if (this._processor == null) { return algebra.Evaluate(this); } else { return this._processor.ProcessAlgebra(algebra, this); } }