Search in sources :

Example 1 with QueryRoot

use of org.openrdf.query.algebra.QueryRoot in project incubator-rya by apache.

the class SparqlToPigTransformVisitorTest method testJoin.

public void testJoin() throws Exception {
    String query = "select * where {\n" + "?subj <urn:lubm:rdfts#name> 'Department0'.\n" + "?subj <urn:lubm:rdfts#subOrganizationOf> <http://www.University0.edu>.\n" + "}";
    // System.out.println(query);
    QueryParser parser = new SPARQLParser();
    ParsedQuery parsedQuery = parser.parseQuery(query, null);
    // System.out.println(parsedQuery);
    SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
    visitor.setTablePrefix(tablePrefix);
    visitor.setInstance(instance);
    visitor.setZk(zk);
    visitor.setUser(user);
    visitor.setPassword(password);
    visitor.meet(new QueryRoot(parsedQuery.getTupleExpr()));
// System.out.println(visitor.getPigScript());
}
Also used : QueryParser(org.openrdf.query.parser.QueryParser) SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser) QueryRoot(org.openrdf.query.algebra.QueryRoot) ParsedQuery(org.openrdf.query.parser.ParsedQuery)

Example 2 with QueryRoot

use of org.openrdf.query.algebra.QueryRoot in project incubator-rya by apache.

the class SparqlToPigTransformVisitorTest method testCross.

public void testCross() throws Exception {
    String query = "select * where {\n" + "?subj0 <urn:lubm:rdfts#name> 'Department0'.\n" + "?subj1 <urn:lubm:rdfts#name> 'Department1'.\n" + "?subj0 <urn:lubm:rdfts#subOrganizationOf> <http://www.University0.edu>.\n" + "?subj1 <urn:lubm:rdfts#subOrganizationOf> <http://www.University0.edu>.\n" + "}";
    // System.out.println(query);
    QueryParser parser = new SPARQLParser();
    ParsedQuery parsedQuery = parser.parseQuery(query, null);
    QueryRoot tupleExpr = new QueryRoot(parsedQuery.getTupleExpr());
    SimilarVarJoinOptimizer similarVarJoinOptimizer = new SimilarVarJoinOptimizer();
    similarVarJoinOptimizer.optimize(tupleExpr, null, null);
    // System.out.println(tupleExpr);
    SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
    visitor.setTablePrefix(tablePrefix);
    visitor.setInstance(instance);
    visitor.setZk(zk);
    visitor.setUser(user);
    visitor.setPassword(password);
    visitor.meet(tupleExpr);
// System.out.println(visitor.getPigScript());
}
Also used : QueryParser(org.openrdf.query.parser.QueryParser) SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser) QueryRoot(org.openrdf.query.algebra.QueryRoot) ParsedQuery(org.openrdf.query.parser.ParsedQuery) SimilarVarJoinOptimizer(org.apache.rya.accumulo.pig.optimizer.SimilarVarJoinOptimizer)

Example 3 with QueryRoot

use of org.openrdf.query.algebra.QueryRoot in project incubator-rya by apache.

the class SparqlToPigTransformVisitorTest method testHardQuery.

public void testHardQuery() throws Exception {
    String query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + " PREFIX ub: <urn:lubm:rdfts#>\n" + " SELECT * WHERE\n" + " {\n" + "        ?y rdf:type ub:University .\n" + "        ?z ub:subOrganizationOf ?y .\n" + "        ?z rdf:type ub:Department .\n" + "        ?x ub:memberOf ?z .\n" + "        ?x ub:undergraduateDegreeFrom ?y .\n" + "       ?x rdf:type ub:GraduateStudent .\n" + " }\n" + "limit 100";
    // String query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" +
    // " PREFIX ub: <urn:lubm:rdfts#>\n" +
    // " SELECT * WHERE\n" +
    // " {\n" +
    // "\t?x ub:advisor ?y.\n" +
    // "\t?y ub:teacherOf ?z.\n" +
    // "\t?x ub:takesCourse ?z.\n" +
    // "\t?x rdf:type ub:Student.\n" +
    // "\t?y rdf:type ub:Faculty.\n" +
    // "\t?z rdf:type ub:Course.\n" +
    // " }\n" +
    // "limit 100";
    // System.out.println(query);
    QueryParser parser = new SPARQLParser();
    ParsedQuery parsedQuery = parser.parseQuery(query, null);
    TupleExpr tupleExpr = parsedQuery.getTupleExpr();
    // CloudbaseRdfEvalStatsDAO rdfEvalStatsDAO = new CloudbaseRdfEvalStatsDAO();
    // rdfEvalStatsDAO.setConnector(new ZooKeeperInstance("stratus", "stratus13:2181").getConnector("root", "password".getBytes()));
    // rdfEvalStatsDAO.setEvalTable("l_eval");
    // RdfCloudTripleStoreEvaluationStatistics stats = new RdfCloudTripleStoreEvaluationStatistics(new Configuration(), rdfEvalStatsDAO);
    // (new SimilarVarJoinOptimizer(stats)).optimize(tupleExpr, null, null);
    // System.out.println(tupleExpr);
    SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
    visitor.setTablePrefix(tablePrefix);
    visitor.setInstance(instance);
    visitor.setZk(zk);
    visitor.setUser(user);
    visitor.setPassword(password);
    visitor.meet(new QueryRoot(tupleExpr));
// System.out.println(visitor.getPigScript());
}
Also used : QueryParser(org.openrdf.query.parser.QueryParser) SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser) QueryRoot(org.openrdf.query.algebra.QueryRoot) ParsedQuery(org.openrdf.query.parser.ParsedQuery) TupleExpr(org.openrdf.query.algebra.TupleExpr)

Example 4 with QueryRoot

use of org.openrdf.query.algebra.QueryRoot in project incubator-rya by apache.

the class SparqlToPigTransformVisitorTest method testMutlipleJoins.

public void testMutlipleJoins() throws Exception {
    String query = "select * where {\n" + "?subj <urn:lubm:rdfts#name> 'Department0'.\n" + "?subj <urn:lubm:rdfts#subOrganizationOf> <http://www.University0.edu>.\n" + "?subj <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <urn:lubm:rdfts#Department>.\n" + "}";
    // System.out.println(query);
    QueryParser parser = new SPARQLParser();
    ParsedQuery parsedQuery = parser.parseQuery(query, null);
    // System.out.println(parsedQuery);
    SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
    visitor.setTablePrefix(tablePrefix);
    visitor.setInstance(instance);
    visitor.setZk(zk);
    visitor.setUser(user);
    visitor.setPassword(password);
    visitor.meet(new QueryRoot(parsedQuery.getTupleExpr()));
// System.out.println(visitor.getPigScript());
}
Also used : QueryParser(org.openrdf.query.parser.QueryParser) SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser) QueryRoot(org.openrdf.query.algebra.QueryRoot) ParsedQuery(org.openrdf.query.parser.ParsedQuery)

Example 5 with QueryRoot

use of org.openrdf.query.algebra.QueryRoot in project incubator-rya by apache.

the class SparqlToPigTransformVisitorTest method testLimit.

public void testLimit() throws Exception {
    String query = "select * where {\n" + "?subj <urn:lubm:rdfts#name> 'Department0'.\n" + "?subj <urn:lubm:rdfts#subOrganizationOf> ?suborg.\n" + "} limit 100";
    // System.out.println(query);
    QueryParser parser = new SPARQLParser();
    ParsedQuery parsedQuery = parser.parseQuery(query, null);
    // System.out.println(parsedQuery);
    SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
    visitor.setTablePrefix(tablePrefix);
    visitor.setInstance(instance);
    visitor.setZk(zk);
    visitor.setUser(user);
    visitor.setPassword(password);
    visitor.meet(new QueryRoot(parsedQuery.getTupleExpr()));
// System.out.println(visitor.getPigScript());
}
Also used : QueryParser(org.openrdf.query.parser.QueryParser) SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser) QueryRoot(org.openrdf.query.algebra.QueryRoot) ParsedQuery(org.openrdf.query.parser.ParsedQuery)

Aggregations

QueryRoot (org.openrdf.query.algebra.QueryRoot)27 Test (org.junit.Test)13 ParsedQuery (org.openrdf.query.parser.ParsedQuery)11 QueryParser (org.openrdf.query.parser.QueryParser)11 SPARQLParser (org.openrdf.query.parser.sparql.SPARQLParser)11 StatementPattern (org.openrdf.query.algebra.StatementPattern)9 Var (org.openrdf.query.algebra.Var)8 BindingSet (org.openrdf.query.BindingSet)5 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)5 Join (org.openrdf.query.algebra.Join)5 QueryBindingSet (org.openrdf.query.algebra.evaluation.QueryBindingSet)5 EmptyBindingSet (org.openrdf.query.impl.EmptyBindingSet)5 TupleExpr (org.openrdf.query.algebra.TupleExpr)4 URI (org.openrdf.model.URI)3 Projection (org.openrdf.query.algebra.Projection)3 ListBindingSet (org.openrdf.query.impl.ListBindingSet)3 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)2 QueryJoinOptimizer (org.apache.rya.rdftriplestore.evaluation.QueryJoinOptimizer)2 InverseOfVisitor (org.apache.rya.rdftriplestore.inference.InverseOfVisitor)2 Extension (org.openrdf.query.algebra.Extension)2