コード例 #1
0
        /// <summary>
        /// Gets the String representation of the Algebra
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            String filter = _filter.ToString();

            filter = filter.Substring(7, filter.Length - 8);
            return("LeftJoin(" + _lhs.ToString() + ", " + _rhs.ToString() + ", " + filter + ")");
        }
コード例 #2
0
        public void FullTextOptimiserComplex3()
        {
            SparqlQuery    q       = this.TestOptimisation("SELECT * WHERE { ?s pf:textMatch 'value' . BIND(STR(?s) AS ?str) }");
            ISparqlAlgebra algebra = q.ToAlgebra();

            Assert.DoesNotContain("PropertyFunction(Extend(", algebra.ToString());
        }
コード例 #3
0
        public void SparqlSequenceUpdateThenQuery2()
        {
            InMemoryDataset          dataset         = new InMemoryDataset();
            LeviathanUpdateProcessor updateProcessor = new LeviathanUpdateProcessor(dataset);
            LeviathanQueryProcessor  queryProcessor  = new LeviathanQueryProcessor(dataset);

            Assert.Equal(1, dataset.Graphs.Count());

            SparqlUpdateCommandSet updates = this._updateParser.ParseFromFile("resources\\sparql\\protocol\\update_dataset_default_graphs.ru");

            updateProcessor.ProcessCommandSet(updates);

            Assert.Equal(5, dataset.Graphs.Count());
            Assert.Equal(2, dataset[UriFactory.Create("http://example.org/protocol-update-dataset-graphs-test/")].Triples.Count());

            SparqlQuery query = this._queryParser.ParseFromFile("resources\\sparql\\protocol\\update_dataset_default_graphs.rq");

            ISparqlAlgebra algebra = query.ToAlgebra();

            Console.WriteLine(algebra.ToString());

            SparqlResultSet results = queryProcessor.ProcessQuery(query) as SparqlResultSet;

            Assert.NotNull(results);
            Assert.Equal(SparqlResultsType.Boolean, results.ResultsType);
            Assert.True(results.Result);
        }
コード例 #4
0
        private void RunTest(ISparqlPath path, IEnumerable <String> expectedOperators)
        {
            VariablePattern      x       = new VariablePattern("?x");
            VariablePattern      y       = new VariablePattern("?y");
            PathTransformContext context = new PathTransformContext(x, y);

            Console.WriteLine("Path: " + path.ToString());

            ISparqlAlgebra algebra = path.ToAlgebra(context);
            String         result  = algebra.ToString();

            Console.WriteLine("Algebra: " + result);

            try
            {
                GraphPattern gp = algebra.ToGraphPattern();
                Console.WriteLine("GraphPattern:");
                Console.WriteLine(this._formatter.Format(gp));
                Console.WriteLine();
            }
            catch
            {
                Console.WriteLine("Algebra not translatable to a GraphPattern");
            }

            foreach (String op in expectedOperators)
            {
                if (result.Contains(op))
                {
                    continue;
                }
                Console.WriteLine("Expected Operator '" + op + "' missing");
                Assert.True(false, "Expected Operator '" + op + "' missing");
            }
        }
コード例 #5
0
        public void FullTextOptimiserComplex4()
        {
            SparqlQuery    q       = this.TestOptimisation("SELECT * WHERE { (?s ?score) pf:textMatch 'value' . BIND(STR(?s) AS ?str) }");
            ISparqlAlgebra algebra = q.ToAlgebra();

            Assert.IsFalse(algebra.ToString().Contains("PropertyFunction(Extend("));
        }
コード例 #6
0
        /// <summary>
        /// Gets the String representation of the FILTER.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            String filter = _filter.ToString();

            filter = filter.Substring(7, filter.Length - 8);
            return(GetType().Name + "(" + _pattern.ToString() + ", " + filter + ")");
        }
コード例 #7
0
        private string TranslateSparqlToSQL(SparqlQuery query)
        {
            //Do Handler null checks before evaluating the query
            if (query == null)
            {
                throw new ArgumentNullException("query", "Cannot evaluate a null query");
            }

            //Reset Query Timers
            query.QueryExecutionTime = null;

            //Convert to Algebra and execute the Query
            //SparqlEvaluationContext context = this.GetContext(query);

            ISparqlAlgebra algebra = query.ToAlgebra();

            Console.WriteLine(algebra.ToString());
            //result = context.Evaluate(algebra); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            return(ProcessAlgebra(algebra));
        }
コード例 #8
0
        private void TestStrictOptimiser(String query, String[] expectedOperators)
        {
            SparqlQuery q = this._parser.ParseFromString(query);

            Console.WriteLine("Query:");
            Console.WriteLine(this._formatter.Format(q));
            Console.WriteLine();

            q.AlgebraOptimisers = new IAlgebraOptimiser[] { this._optimiser };
            ISparqlAlgebra algebra = q.ToAlgebra();
            String         output  = algebra.ToString();

            Console.WriteLine("Algebra:");
            Console.WriteLine(output);
            Console.WriteLine();

            foreach (String op in expectedOperators)
            {
                Assert.True(output.Contains(op), "Should have contained " + op + " Operator");
            }
        }
コード例 #9
0
        public void SparqlBindScope6()
        {
            String query = @"PREFIX : <http://example.org>
SELECT *
WHERE
{
  {
    GRAPH ?g { :s :p ?o }
    BIND (?g AS ?in)
  }
  UNION
  {
    :s :p ?o .
    BIND('default' AS ?in)
  }
}";

            SparqlQueryParser parser = new SparqlQueryParser();
            SparqlQuery       q      = parser.ParseFromString(query);

            Console.WriteLine(q.ToString());

            ISparqlAlgebra algebra = q.ToAlgebra();

            Console.WriteLine(algebra.ToString());
            Assert.IsInstanceOfType(algebra, typeof(Select));

            algebra = ((IUnaryOperator)algebra).InnerAlgebra;
            Assert.IsInstanceOfType(algebra, typeof(Union));

            IUnion         union = (Union)algebra;
            ISparqlAlgebra lhs   = union.Lhs;

            Assert.IsInstanceOfType(lhs, typeof(Extend));

            ISparqlAlgebra rhs = union.Rhs;

            Assert.IsInstanceOfType(rhs, typeof(Join));
        }
コード例 #10
0
        public void SparqlBindScope5()
        {
            String query = @"PREFIX : <http://example.org>
SELECT *
WHERE
{
  GRAPH ?g { :s :p ?o }
  BIND (?g AS ?in)
}";

            SparqlQueryParser parser = new SparqlQueryParser();
            SparqlQuery       q      = parser.ParseFromString(query);

            Console.WriteLine(q.ToString());

            ISparqlAlgebra algebra = q.ToAlgebra();

            Console.WriteLine(algebra.ToString());
            Assert.IsInstanceOfType(algebra, typeof(Select));

            algebra = ((IUnaryOperator)algebra).InnerAlgebra;
            Assert.IsInstanceOfType(algebra, typeof(Extend));
        }
コード例 #11
0
        public void FullTextOptimiserComplex5()
        {
            //Actual test case from FTXT-364
            String         query   = @"PREFIX rdf: <" + NamespaceMapper.RDF + @">
PREFIX rdfs: <" + NamespaceMapper.RDFS + @">
PREFIX my: <http://example.org/my#>

SELECT DISTINCT ?result ?isWebSite WHERE {
        _:sparql-autos2 rdf:rest rdf:nil .
        _:sparql-autos1 rdf:rest _:sparql-autos2 .
        _:sparql-autos2 rdf:first ?score .
        _:sparql-autos1 pf:textMatch _:sparql-autos3 .
        _:sparql-autos1 rdf:first ?result .
        BIND(IF (EXISTS { ?result a my:PersonalSite . } , true , false) AS ?isWebSite) .
        _:sparql-autos3 rdf:first 'securite~' .
        _:sparql-autos3 rdf:rest rdf:nil .
       ?result a my:Organization .
       ?result rdfs:label ?label .
    } ORDER BY DESC(?isWebSite) DESC(?score) ASC(?label)";
            SparqlQuery    q       = this.TestOptimisation(query);
            ISparqlAlgebra algebra = q.ToAlgebra();

            Assert.IsFalse(algebra.ToString().Contains("PropertyFunction(Extend("));
        }
コード例 #12
0
 /// <summary>
 /// Gets the String representation of the Algebra.
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return("OrderBy(" + _pattern.ToString() + ")");
 }
コード例 #13
0
 /// <summary>
 /// Gets the String representation of the Algebra
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return("ExistsJoin(" + _lhs.ToString() + ", " + _rhs.ToString() + ", " + _mustExist + ")");
 }
コード例 #14
0
 /// <summary>
 /// Gets the string represenation of the algebra.
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return("FilteredProduct(" + _lhs.ToString() + ", " + _rhs.ToString() + ", " + _expr.ToString() + ")");
 }
コード例 #15
0
 /// <summary>
 /// Gets the String representation of the Algebra.
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return("Slice(" + _pattern.ToString() + ", LIMIT " + _limit + ", OFFSET " + _offset + ")");
 }
コード例 #16
0
 /// <summary>
 /// Gets the String representation of the Algebra.
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return("Reduced(" + _pattern.ToString() + ")");
 }
コード例 #17
0
ファイル: GroupBy.cs プロジェクト: adamthe30/KADL-iet-2018
 /// <summary>
 /// Gets the String representation of the
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return("GroupBy(" + _pattern.ToString() + ")");
 }
コード例 #18
0
 /// <summary>
 /// Gets the string representation of the algebra.
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return("PropertyFunction(" + _algebra.ToString() + "," + _function.FunctionUri + ")");
 }
コード例 #19
0
 /// <summary>
 /// Gets the String representation of the Join
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return("Join(" + _lhs.ToString() + ", " + _rhs.ToString() + ")");
 }
コード例 #20
0
ファイル: LazyBgp.cs プロジェクト: vermeerlee/dotnetrdf
 /// <summary>
 /// Gets the String representation of the Algebra.
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return("LazyUnion(" + _lhs.ToString() + ", " + _rhs.ToString() + ")");
 }
コード例 #21
0
 /// <summary>
 /// Gets the String representation of the Algebra.
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return("Having(" + _pattern.ToString() + ")");
 }
コード例 #22
0
 /// <summary>
 /// Gets the String representation of the Algebra
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return("Select(" + _pattern.ToString() + ")");
 }
コード例 #23
0
 /// <summary>
 /// Gets the String representation of the Algebra.
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return("Distinct(" + _pattern.ToString() + ")");
 }
コード例 #24
0
ファイル: Graph.cs プロジェクト: adamthe30/KADL-iet-2018
 /// <summary>
 /// Gets the String representation of the Algebra
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return("Graph(" + _graphSpecifier.Value + ", " + _pattern.ToString() + ")");
 }
コード例 #25
0
 /// <summary>
 /// Gets the String representation of the Algebra
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return("ParallelUnion(" + _lhs.ToString() + ", " + _rhs.ToString() + ")");
 }