Search in sources :

Example 21 with URIImpl

use of org.openrdf.model.impl.URIImpl in project incubator-rya by apache.

the class AccumuloPcjIT method testEvaluateTwoIndexThreeVarOrder4ThreeBindingSet.

@Test
public void testEvaluateTwoIndexThreeVarOrder4ThreeBindingSet() throws PcjException, RepositoryException, AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException, TupleQueryResultHandlerException, QueryEvaluationException, MalformedQueryException, SailException {
    final URI sub3 = new URIImpl("uri:entity3");
    final URI subclass3 = new URIImpl("uri:class3");
    final URI obj3 = new URIImpl("uri:obj3");
    final URI superclass = new URIImpl("uri:superclass");
    final URI superclass2 = new URIImpl("uri:superclass2");
    final URI superclass3 = new URIImpl("uri:superclass3");
    conn.add(sub3, RDF.TYPE, subclass3);
    conn.add(sub3, RDFS.LABEL, new LiteralImpl("label3"));
    conn.add(sub3, talksTo, obj3);
    conn.add(subclass, RDF.TYPE, superclass);
    conn.add(subclass2, RDF.TYPE, superclass2);
    conn.add(subclass3, RDF.TYPE, superclass3);
    conn.add(obj, RDFS.LABEL, new LiteralImpl("label"));
    conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2"));
    conn.add(obj3, RDFS.LABEL, new LiteralImpl("label3"));
    conn.add(obj, RDFS.LABEL, new LiteralImpl("label"));
    conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2"));
    final String indexSparqlString = // 
    "" + // 
    "SELECT ?c ?e ?l  " + // 
    "{" + // 
    "  ?e a ?c . " + // 
    "  ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l " + // 
    "}";
    final String indexSparqlString2 = // 
    "" + // 
    "SELECT ?o ?f ?c ?e ?l  " + // 
    "{" + // 
    "  ?e <uri:talksTo> ?o . " + // 
    "  ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. " + // 
    "  ?c a ?f . " + // 
    "}";
    final String queryString = // 
    "" + // 
    "SELECT ?e ?c ?l ?f ?o " + // 
    "{" + // 
    "  ?e a ?c . " + // 
    "  ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l. " + // 
    "  ?e <uri:talksTo> ?o . " + // 
    "  ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. " + // 
    "  ?c a ?f . " + // 
    "}";
    final CountingResultHandler crh1 = new CountingResultHandler();
    final CountingResultHandler crh2 = new CountingResultHandler();
    PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablename + 1, indexSparqlString, new String[] { "c", "e", "l" }, Optional.<PcjVarOrderFactory>absent());
    PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablename + 2, indexSparqlString2, new String[] { "o", "f", "c", "e", "l" }, Optional.<PcjVarOrderFactory>absent());
    conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh1);
    PcjIntegrationTestingUtil.deleteCoreRyaTables(accCon, prefix);
    pcjConn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh2);
    Assert.assertEquals(3, crh1.getCount());
    Assert.assertEquals(3, crh2.getCount());
}
Also used : LiteralImpl(org.openrdf.model.impl.LiteralImpl) URIImpl(org.openrdf.model.impl.URIImpl) URI(org.openrdf.model.URI) Test(org.junit.Test)

Example 22 with URIImpl

use of org.openrdf.model.impl.URIImpl in project incubator-rya by apache.

the class AccumuloPcjIT method testEvaluateThreeIndexValidate.

@Test
public void testEvaluateThreeIndexValidate() throws Exception {
    final URI superclass = new URIImpl("uri:superclass");
    final URI superclass2 = new URIImpl("uri:superclass2");
    final URI sub = new URIImpl("uri:entity");
    subclass = new URIImpl("uri:class");
    obj = new URIImpl("uri:obj");
    talksTo = new URIImpl("uri:talksTo");
    final URI howlsAt = new URIImpl("uri:howlsAt");
    final URI subType = new URIImpl("uri:subType");
    final URI superSuperclass = new URIImpl("uri:super_superclass");
    conn.add(subclass, RDF.TYPE, superclass);
    conn.add(subclass2, RDF.TYPE, superclass2);
    conn.add(obj, RDFS.LABEL, new LiteralImpl("label"));
    conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2"));
    conn.add(sub, howlsAt, superclass);
    conn.add(superclass, subType, superSuperclass);
    conn.add(obj, RDFS.LABEL, new LiteralImpl("label"));
    conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2"));
    final String indexSparqlString = // 
    "" + // 
    "SELECT ?dog ?pig ?duck  " + // 
    "{" + // 
    "  ?pig a ?dog . " + // 
    "  ?pig <http://www.w3.org/2000/01/rdf-schema#label> ?duck " + // 
    "}";
    final String indexSparqlString2 = // 
    "" + // 
    "SELECT ?o ?f ?e ?c ?l  " + // 
    "{" + // 
    "  ?e <uri:talksTo> ?o . " + // 
    "  ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. " + // 
    "  ?c a ?f . " + // 
    "}";
    final String indexSparqlString3 = // 
    "" + // 
    "SELECT ?wolf ?sheep ?chicken  " + // 
    "{" + // 
    "  ?wolf <uri:howlsAt> ?sheep . " + // 
    "  ?sheep <uri:subType> ?chicken. " + // 
    "}";
    final String queryString = // 
    "" + // 
    "SELECT ?e ?c ?l ?f ?o " + // 
    "{" + // 
    "  ?e a ?c . " + // 
    "  ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l. " + // 
    "  ?e <uri:talksTo> ?o . " + // 
    "  ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. " + // 
    "  ?c a ?f . " + // 
    "  ?e <uri:howlsAt> ?f. " + // 
    "  ?f <uri:subType> ?o. " + // 
    "}";
    PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablename + 1, indexSparqlString, new String[] { "dog", "pig", "duck" }, Optional.<PcjVarOrderFactory>absent());
    final AccumuloIndexSet ais1 = new AccumuloIndexSet(conf, tablename + 1);
    PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablename + 2, indexSparqlString2, new String[] { "o", "f", "e", "c", "l" }, Optional.<PcjVarOrderFactory>absent());
    final AccumuloIndexSet ais2 = new AccumuloIndexSet(conf, tablename + 2);
    PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablename + 3, indexSparqlString3, new String[] { "wolf", "sheep", "chicken" }, Optional.<PcjVarOrderFactory>absent());
    final AccumuloIndexSet ais3 = new AccumuloIndexSet(conf, tablename + 3);
    final List<ExternalTupleSet> index = new ArrayList<>();
    index.add(ais1);
    index.add(ais3);
    index.add(ais2);
    ParsedQuery pq = null;
    final SPARQLParser sp = new SPARQLParser();
    pq = sp.parseQuery(queryString, null);
    final List<TupleExpr> teList = Lists.newArrayList();
    final TupleExpr te = pq.getTupleExpr();
    final PCJOptimizer pcj = new PCJOptimizer(index, false, new AccumuloIndexSetProvider(conf));
    pcj.optimize(te, null, null);
    teList.add(te);
    final IndexPlanValidator ipv = new IndexPlanValidator(false);
    Assert.assertTrue(ipv.isValid(te));
}
Also used : SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser) AccumuloIndexSet(org.apache.rya.indexing.external.tupleSet.AccumuloIndexSet) ParsedQuery(org.openrdf.query.parser.ParsedQuery) AccumuloIndexSetProvider(org.apache.rya.indexing.pcj.matching.provider.AccumuloIndexSetProvider) ArrayList(java.util.ArrayList) IndexPlanValidator(org.apache.rya.indexing.IndexPlanValidator.IndexPlanValidator) URIImpl(org.openrdf.model.impl.URIImpl) URI(org.openrdf.model.URI) TupleExpr(org.openrdf.query.algebra.TupleExpr) ExternalTupleSet(org.apache.rya.indexing.external.tupleSet.ExternalTupleSet) LiteralImpl(org.openrdf.model.impl.LiteralImpl) PCJOptimizer(org.apache.rya.indexing.pcj.matching.PCJOptimizer) Test(org.junit.Test)

Example 23 with URIImpl

use of org.openrdf.model.impl.URIImpl in project incubator-rya by apache.

the class AccumuloPcjIT method testSupportedVarOrders1.

@Test
public void testSupportedVarOrders1() throws PcjException, RepositoryException, AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException, MalformedQueryException, SailException, QueryEvaluationException {
    final URI superclass = new URIImpl("uri:superclass");
    final URI superclass2 = new URIImpl("uri:superclass2");
    conn.add(subclass, RDF.TYPE, superclass);
    conn.add(subclass2, RDF.TYPE, superclass2);
    conn.add(obj, RDFS.LABEL, new LiteralImpl("label"));
    conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2"));
    conn.add(obj, RDFS.LABEL, new LiteralImpl("label"));
    conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2"));
    final String indexSparqlString = // 
    "" + // 
    "SELECT ?dog ?pig ?duck  " + // 
    "{" + // 
    "  ?pig a ?dog . " + // 
    "  ?pig <http://www.w3.org/2000/01/rdf-schema#label> ?duck " + // 
    "}";
    final String indexSparqlString2 = // 
    "" + // 
    "SELECT ?o ?f ?e ?c ?l  " + // 
    "{" + // 
    "  ?e <uri:talksTo> ?o . " + // 
    "  ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. " + // 
    "  ?c a ?f . " + // 
    "}";
    PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablename + 1, indexSparqlString, new String[] { "dog", "pig", "duck" }, Optional.<PcjVarOrderFactory>absent());
    final AccumuloIndexSet ais1 = new AccumuloIndexSet(conf, tablename + 1);
    PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablename + 2, indexSparqlString2, new String[] { "o", "f", "e", "c", "l" }, Optional.<PcjVarOrderFactory>absent());
    final AccumuloIndexSet ais2 = new AccumuloIndexSet(conf, tablename + 2);
    final Set<String> ais1Set1 = Sets.newHashSet();
    ais1Set1.add("dog");
    Assert.assertTrue(ais1.supportsBindingSet(ais1Set1));
    ais1Set1.add("duck");
    Assert.assertTrue(ais1.supportsBindingSet(ais1Set1));
    ais1Set1.add("chicken");
    Assert.assertTrue(ais1.supportsBindingSet(ais1Set1));
    final Set<String> ais2Set1 = Sets.newHashSet();
    ais2Set1.add("f");
    Assert.assertTrue(ais2.supportsBindingSet(ais2Set1));
    ais2Set1.add("e");
    Assert.assertTrue(ais2.supportsBindingSet(ais2Set1));
    ais2Set1.add("o");
    Assert.assertTrue(ais2.supportsBindingSet(ais2Set1));
    ais2Set1.add("l");
    Assert.assertTrue(ais2.supportsBindingSet(ais2Set1));
    final Set<String> ais2Set2 = Sets.newHashSet();
    ais2Set2.add("f");
    Assert.assertTrue(ais2.supportsBindingSet(ais2Set2));
    ais2Set2.add("o");
    Assert.assertTrue(ais2.supportsBindingSet(ais2Set2));
    ais2Set2.add("c");
    Assert.assertTrue(!ais2.supportsBindingSet(ais2Set2));
    final Set<String> ais2Set3 = Sets.newHashSet();
    ais2Set3.add("c");
    Assert.assertTrue(ais2.supportsBindingSet(ais2Set3));
    ais2Set3.add("e");
    Assert.assertTrue(ais2.supportsBindingSet(ais2Set3));
    ais2Set3.add("l");
    Assert.assertTrue(ais2.supportsBindingSet(ais2Set3));
}
Also used : LiteralImpl(org.openrdf.model.impl.LiteralImpl) AccumuloIndexSet(org.apache.rya.indexing.external.tupleSet.AccumuloIndexSet) URIImpl(org.openrdf.model.impl.URIImpl) URI(org.openrdf.model.URI) Test(org.junit.Test)

Example 24 with URIImpl

use of org.openrdf.model.impl.URIImpl in project incubator-rya by apache.

the class AccumuloPcjIT method testEvaluateTwoIndexThreeVarOrder3ThreeBindingSet.

@Test
public void testEvaluateTwoIndexThreeVarOrder3ThreeBindingSet() throws TupleQueryResultHandlerException, QueryEvaluationException, MalformedQueryException, RepositoryException, AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException, PcjException, SailException {
    final URI sub3 = new URIImpl("uri:entity3");
    final URI subclass3 = new URIImpl("uri:class3");
    final URI obj3 = new URIImpl("uri:obj3");
    final URI superclass = new URIImpl("uri:superclass");
    final URI superclass2 = new URIImpl("uri:superclass2");
    final URI superclass3 = new URIImpl("uri:superclass3");
    conn.add(sub3, RDF.TYPE, subclass3);
    conn.add(sub3, RDFS.LABEL, new LiteralImpl("label3"));
    conn.add(sub3, talksTo, obj3);
    conn.add(subclass, RDF.TYPE, superclass);
    conn.add(subclass2, RDF.TYPE, superclass2);
    conn.add(subclass3, RDF.TYPE, superclass3);
    conn.add(obj, RDFS.LABEL, new LiteralImpl("label"));
    conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2"));
    conn.add(obj3, RDFS.LABEL, new LiteralImpl("label3"));
    conn.add(obj, RDFS.LABEL, new LiteralImpl("label"));
    conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2"));
    final String indexSparqlString = // 
    "" + // 
    "SELECT ?c ?e ?l  " + // 
    "{" + // 
    "  ?e a ?c . " + // 
    "  ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l " + // 
    "}";
    final String indexSparqlString2 = // 
    "" + // 
    "SELECT ?o ?f ?l ?e ?c  " + // 
    "{" + // 
    "  ?e <uri:talksTo> ?o . " + // 
    "  ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. " + // 
    "  ?c a ?f . " + // 
    "}";
    final String queryString = // 
    "" + // 
    "SELECT ?e ?c ?l ?f ?o " + // 
    "{" + // 
    "  ?e a ?c . " + // 
    "  ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l. " + // 
    "  ?e <uri:talksTo> ?o . " + // 
    "  ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. " + // 
    "  ?c a ?f . " + // 
    "}";
    final CountingResultHandler crh1 = new CountingResultHandler();
    final CountingResultHandler crh2 = new CountingResultHandler();
    PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablename + 1, indexSparqlString, new String[] { "c", "e", "l" }, Optional.<PcjVarOrderFactory>absent());
    PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablename + 2, indexSparqlString2, new String[] { "o", "f", "l", "e", "c" }, Optional.<PcjVarOrderFactory>absent());
    conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh1);
    PcjIntegrationTestingUtil.deleteCoreRyaTables(accCon, prefix);
    pcjConn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh2);
    Assert.assertEquals(3, crh1.getCount());
    Assert.assertEquals(3, crh2.getCount());
}
Also used : LiteralImpl(org.openrdf.model.impl.LiteralImpl) URIImpl(org.openrdf.model.impl.URIImpl) URI(org.openrdf.model.URI) Test(org.junit.Test)

Example 25 with URIImpl

use of org.openrdf.model.impl.URIImpl in project incubator-rya by apache.

the class AccumuloPcjIT method testEvaluateTwoIndexThreeVarOrder6ThreeBindingSet.

@Test
public void testEvaluateTwoIndexThreeVarOrder6ThreeBindingSet() throws MalformedQueryException, RepositoryException, AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException, PcjException, TupleQueryResultHandlerException, QueryEvaluationException, SailException {
    final URI sub3 = new URIImpl("uri:entity3");
    final URI subclass3 = new URIImpl("uri:class3");
    final URI obj3 = new URIImpl("uri:obj3");
    final URI superclass = new URIImpl("uri:superclass");
    final URI superclass2 = new URIImpl("uri:superclass2");
    final URI superclass3 = new URIImpl("uri:superclass3");
    conn.add(sub3, RDF.TYPE, subclass3);
    conn.add(sub3, RDFS.LABEL, new LiteralImpl("label3"));
    conn.add(sub3, talksTo, obj3);
    conn.add(subclass, RDF.TYPE, superclass);
    conn.add(subclass2, RDF.TYPE, superclass2);
    conn.add(subclass3, RDF.TYPE, superclass3);
    conn.add(obj, RDFS.LABEL, new LiteralImpl("label"));
    conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2"));
    conn.add(obj3, RDFS.LABEL, new LiteralImpl("label3"));
    conn.add(obj, RDFS.LABEL, new LiteralImpl("label"));
    conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2"));
    final String indexSparqlString = // 
    "" + // 
    "SELECT ?c ?e ?l  " + // 
    "{" + // 
    "  ?e a ?c . " + // 
    "  ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l " + // 
    "}";
    final String indexSparqlString2 = // 
    "" + // 
    "SELECT ?c ?l ?e ?o ?f " + // 
    "{" + // 
    "  ?e <uri:talksTo> ?o . " + // 
    "  ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. " + // 
    "  ?c a ?f . " + // 
    "}";
    final String queryString = // 
    "" + // 
    "SELECT ?e ?c ?l ?f ?o " + // 
    "{" + // 
    "  ?e a ?c . " + // 
    "  ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l. " + // 
    "  ?e <uri:talksTo> ?o . " + // 
    "  ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. " + // 
    "  ?c a ?f . " + // 
    "}";
    final CountingResultHandler crh1 = new CountingResultHandler();
    final CountingResultHandler crh2 = new CountingResultHandler();
    PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablename + 1, indexSparqlString, new String[] { "c", "e", "l" }, Optional.<PcjVarOrderFactory>absent());
    PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablename + 2, indexSparqlString2, new String[] { "c", "l", "e", "o", "f" }, Optional.<PcjVarOrderFactory>absent());
    conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh1);
    PcjIntegrationTestingUtil.deleteCoreRyaTables(accCon, prefix);
    pcjConn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh2);
    Assert.assertEquals(3, crh1.getCount());
    Assert.assertEquals(3, crh2.getCount());
}
Also used : LiteralImpl(org.openrdf.model.impl.LiteralImpl) URIImpl(org.openrdf.model.impl.URIImpl) URI(org.openrdf.model.URI) Test(org.junit.Test)

Aggregations

URIImpl (org.openrdf.model.impl.URIImpl)165 Test (org.junit.Test)116 LiteralImpl (org.openrdf.model.impl.LiteralImpl)61 URI (org.openrdf.model.URI)58 BindingSet (org.openrdf.query.BindingSet)50 MapBindingSet (org.openrdf.query.impl.MapBindingSet)36 RyaURI (org.apache.rya.api.domain.RyaURI)33 HashSet (java.util.HashSet)31 Statement (org.openrdf.model.Statement)30 QueryBindingSet (org.openrdf.query.algebra.evaluation.QueryBindingSet)30 ArrayList (java.util.ArrayList)29 RyaType (org.apache.rya.api.domain.RyaType)25 VisibilityBindingSet (org.apache.rya.api.model.VisibilityBindingSet)24 RyaStatement (org.apache.rya.api.domain.RyaStatement)23 NumericLiteralImpl (org.openrdf.model.impl.NumericLiteralImpl)22 Value (org.openrdf.model.Value)21 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)21 StatementPattern (org.openrdf.query.algebra.StatementPattern)20 StatementImpl (org.openrdf.model.impl.StatementImpl)19 PcjMetadata (org.apache.rya.indexing.pcj.storage.PcjMetadata)16