use of org.openrdf.model.impl.LiteralImpl in project incubator-rya by apache.
the class AccumuloConstantPcjIT method init.
@Before
public void init() throws RepositoryException, TupleQueryResultHandlerException, QueryEvaluationException, MalformedQueryException, AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException, RyaDAOException, InferenceEngineException, NumberFormatException, UnknownHostException, SailException {
repo = PcjIntegrationTestingUtil.getAccumuloNonPcjRepo(prefix, "instance");
conn = repo.getConnection();
pcjRepo = PcjIntegrationTestingUtil.getAccumuloPcjRepo(prefix, "instance");
pcjConn = pcjRepo.getConnection();
final URI sub = new URIImpl("uri:entity");
subclass = new URIImpl("uri:class");
obj = new URIImpl("uri:obj");
talksTo = new URIImpl("uri:talksTo");
conn.add(sub, RDF.TYPE, subclass);
conn.add(sub, RDFS.LABEL, new LiteralImpl("label"));
conn.add(sub, talksTo, obj);
final URI sub2 = new URIImpl("uri:entity2");
subclass2 = new URIImpl("uri:class2");
obj2 = new URIImpl("uri:obj2");
conn.add(sub2, RDF.TYPE, subclass2);
conn.add(sub2, RDFS.LABEL, new LiteralImpl("label2"));
conn.add(sub2, talksTo, obj2);
accCon = new MockInstance("instance").getConnector("root", new PasswordToken(""));
}
use of org.openrdf.model.impl.LiteralImpl in project incubator-rya by apache.
the class AccumuloConstantPcjIT method testEvaluateTwoIndexVarInstantiate1.
@Test
public void testEvaluateTwoIndexVarInstantiate1() throws PcjException, RepositoryException, AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException, MalformedQueryException, SailException, QueryEvaluationException, TupleQueryResultHandlerException {
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 . " + //
"}";
final String queryString = //
"" + //
"SELECT ?c ?l ?f ?o " + //
"{" + //
" <uri:entity> a ?c . " + //
" <uri:entity> <http://www.w3.org/2000/01/rdf-schema#label> ?l. " + //
" <uri:entity> <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());
PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablename + 2, indexSparqlString2, new String[] { "o", "f", "e", "c", "l" }, Optional.<PcjVarOrderFactory>absent());
final CountingResultHandler crh1 = new CountingResultHandler();
final CountingResultHandler crh2 = new CountingResultHandler();
conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh1);
PcjIntegrationTestingUtil.deleteCoreRyaTables(accCon, prefix);
pcjConn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh2);
Assert.assertEquals(crh1.getCount(), crh2.getCount());
}
use of org.openrdf.model.impl.LiteralImpl in project incubator-rya by apache.
the class PrecompJoinOptimizerIT method testEvaluateTwoIndexLeftJoinUnionFilter.
@Test
public void testEvaluateTwoIndexLeftJoinUnionFilter() throws AccumuloException, AccumuloSecurityException, TableExistsException, RepositoryException, MalformedQueryException, SailException, QueryEvaluationException, TableNotFoundException, TupleQueryResultHandlerException, RyaDAOException, PcjException, InferenceEngineException, NumberFormatException, UnknownHostException {
conn.add(obj, RDFS.LABEL, new LiteralImpl("label"));
conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2"));
conn.add(sub, RDF.TYPE, obj);
conn.add(sub2, RDF.TYPE, obj2);
final URI livesIn = new URIImpl("uri:livesIn");
final URI city = new URIImpl("uri:city");
final URI city2 = new URIImpl("uri:city2");
final URI city3 = new URIImpl("uri:city3");
conn.add(sub, livesIn, city);
conn.add(sub2, livesIn, city2);
conn.add(sub2, livesIn, city3);
conn.add(sub, livesIn, city3);
final String indexSparqlString = //
"" + //
"SELECT ?e ?l ?o " + //
"{" + //
" ?e a ?o . " + //
" ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l " + //
"}";
final String indexSparqlString2 = //
"" + //
"SELECT ?e ?l ?o " + //
"{" + //
" ?e <uri:talksTo> ?o . " + //
" ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l " + //
"}";
final String queryString = //
"" + //
"SELECT ?c ?e ?l ?o " + //
"{" + //
" Filter(?c = <uri:city3>) " + //
" ?e <uri:livesIn> ?c . " + //
" OPTIONAL{{ ?e a ?o . ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l }" + //
" UNION { ?e <uri:talksTo> ?o . ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l }}" + //
"}";
PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablePrefix + "INDEX_1", indexSparqlString, new String[] { "e", "l", "o" }, Optional.<PcjVarOrderFactory>absent());
PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablePrefix + "INDEX_2", indexSparqlString2, new String[] { "e", "l", "o" }, Optional.<PcjVarOrderFactory>absent());
PcjIntegrationTestingUtil.deleteCoreRyaTables(accCon, tablePrefix);
PcjIntegrationTestingUtil.closeAndShutdown(conn, repo);
repo = PcjIntegrationTestingUtil.getAccumuloPcjRepo(tablePrefix, "instance");
conn = repo.getConnection();
conn.add(sub2, livesIn, city3);
conn.add(sub, livesIn, city3);
final CountingResultHandler crh = new CountingResultHandler();
pcjConn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh);
Assert.assertEquals(6, crh.getCount());
}
use of org.openrdf.model.impl.LiteralImpl in project incubator-rya by apache.
the class PrecompJoinOptimizerIT method testEvaluateTwoIndexTwoVarOrder1.
@Test
public void testEvaluateTwoIndexTwoVarOrder1() throws AccumuloException, AccumuloSecurityException, TableExistsException, RepositoryException, MalformedQueryException, SailException, QueryEvaluationException, TableNotFoundException, TupleQueryResultHandlerException, RyaDAOException, PcjException {
conn.add(obj, RDFS.LABEL, new LiteralImpl("label"));
conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2"));
final String indexSparqlString = //
"" + //
"SELECT ?e ?l ?c " + //
"{" + //
" ?e a ?c . " + //
" ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l " + //
"}";
final String indexSparqlString2 = //
"" + //
"SELECT ?e ?o ?l " + //
"{" + //
" ?e <uri:talksTo> ?o . " + //
" ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l " + //
"}";
final String queryString = //
"" + //
"SELECT ?e ?c ?l ?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 " + //
"}";
PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablePrefix + "INDEX_1", indexSparqlString, new String[] { "e", "l", "c" }, Optional.<PcjVarOrderFactory>absent());
PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablePrefix + "INDEX_2", indexSparqlString2, new String[] { "e", "l", "o" }, Optional.<PcjVarOrderFactory>absent());
final CountingResultHandler crh = new CountingResultHandler();
PcjIntegrationTestingUtil.deleteCoreRyaTables(accCon, tablePrefix);
pcjConn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh);
Assert.assertEquals(2, crh.getCount());
}
use of org.openrdf.model.impl.LiteralImpl in project incubator-rya by apache.
the class PrecompJoinOptimizerIT method testEvaluateTwoIndexUnionFilter.
@Test
public void testEvaluateTwoIndexUnionFilter() throws AccumuloException, AccumuloSecurityException, TableExistsException, RepositoryException, MalformedQueryException, SailException, QueryEvaluationException, TableNotFoundException, TupleQueryResultHandlerException, RyaDAOException, PcjException, InferenceEngineException, NumberFormatException, UnknownHostException {
conn.add(obj, RDFS.LABEL, new LiteralImpl("label"));
conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2"));
conn.add(sub, RDF.TYPE, obj);
conn.add(sub2, RDF.TYPE, obj2);
final String indexSparqlString = //
"" + //
"SELECT ?e ?l ?o " + //
"{" + //
" Filter(?l = \"label2\") " + //
" ?e a ?o . " + //
" ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l " + //
"}";
final String indexSparqlString2 = //
"" + //
"SELECT ?e ?l ?o " + //
"{" + //
" Filter(?l = \"label2\") " + //
" ?e <uri:talksTo> ?o . " + //
" ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l " + //
"}";
final String queryString = //
"" + //
"SELECT ?c ?e ?l ?o " + //
"{" + //
" Filter(?l = \"label2\") " + //
" ?e a ?c . " + //
" { ?e a ?o . ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l }" + //
" UNION { ?e <uri:talksTo> ?o . ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l }" + //
"}";
PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablePrefix + "INDEX_1", indexSparqlString, new String[] { "e", "l", "o" }, Optional.<PcjVarOrderFactory>absent());
PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablePrefix + "INDEX_2", indexSparqlString2, new String[] { "e", "l", "o" }, Optional.<PcjVarOrderFactory>absent());
PcjIntegrationTestingUtil.deleteCoreRyaTables(accCon, tablePrefix);
PcjIntegrationTestingUtil.closeAndShutdown(conn, repo);
repo = PcjIntegrationTestingUtil.getAccumuloPcjRepo(tablePrefix, "instance");
conn = repo.getConnection();
conn.add(sub2, RDF.TYPE, subclass2);
conn.add(sub2, RDF.TYPE, obj2);
final CountingResultHandler crh = new CountingResultHandler();
pcjConn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh);
Assert.assertEquals(6, crh.getCount());
}
Aggregations