Ejemplo n.º 1
0
        public void SparqlSetDistinct1()
        {
            INode a  = this._factory.CreateBlankNode();
            INode b1 = (1).ToLiteral(this._factory);
            INode b2 = (2).ToLiteral(this._factory);

            Set x = new Set();

            x.Add("a", a);
            x.Add("_:b", b1);

            Set y = new Set();

            y.Add("a", a);
            y.Add("_:b", b2);

            Assert.AreNotEqual(x, y);

            Multiset data = new Multiset();

            data.Add(x);
            data.Add(y);
            Assert.AreEqual(2, data.Count);

            Table    table    = new Table(data);
            Distinct distinct = new Distinct(table);

            //Distinct should yield a single result since temporary variables
            //are stripped
            SparqlEvaluationContext context = new SparqlEvaluationContext(null, null);
            BaseMultiset            results = distinct.Evaluate(context);

            Assert.AreEqual(1, results.Count);
            Assert.IsFalse(results.ContainsVariable("_:b"));
        }
Ejemplo n.º 2
0
        public void SparqlSetDistinct2()
        {
            INode a  = this._factory.CreateBlankNode();
            INode b1 = (1).ToLiteral(this._factory);
            INode b2 = (2).ToLiteral(this._factory);

            Set x = new Set();

            x.Add("a", a);
            x.Add("_:b", b1);

            Set y = new Set();

            y.Add("a", a);
            y.Add("_:b", b2);

            Assert.NotEqual(x, y);

            Multiset data = new Multiset();

            data.Add(x);
            data.Add(y);
            Assert.Equal(2, data.Count);

            Table    table    = new Table(data);
            Distinct distinct = new Distinct(table, true);

            //Distinct should yield two result and temporary variables should still
            //be present
            SparqlEvaluationContext context = new SparqlEvaluationContext(null, null);
            BaseMultiset            results = distinct.Evaluate(context);

            Assert.Equal(2, results.Count);
            Assert.True(results.ContainsVariable("_:b"));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Processes a Distinct modifier
 /// </summary>
 /// <param name="distinct">Distinct modifier</param>
 /// <param name="context">SPARQL Evaluation Context</param>
 public virtual BaseMultiset ProcessDistinct(Distinct distinct, SparqlEvaluationContext context)
 {
     if (context == null)
     {
         context = this.GetContext();
     }
     return(distinct.Evaluate(context));
 }