use of org.openrdf.model.impl.LiteralImpl in project incubator-rya by apache.
the class MongoStatementMetadataNodeIT method simpleQueryWithoutBindingSet.
@Test
public void simpleQueryWithoutBindingSet() throws Exception {
MongoDBRyaDAO dao = new MongoDBRyaDAO();
try {
dao.setConf(conf);
dao.init();
StatementMetadata metadata = new StatementMetadata();
metadata.addMetadata(new RyaURI("http://createdBy"), new RyaType("Joe"));
metadata.addMetadata(new RyaURI("http://createdOn"), new RyaType(XMLSchema.DATE, "2017-01-04"));
RyaStatement statement = new RyaStatement(new RyaURI("http://Joe"), new RyaURI("http://worksAt"), new RyaType("CoffeeShop"), new RyaURI("http://context"), "", metadata);
dao.add(statement);
SPARQLParser parser = new SPARQLParser();
ParsedQuery pq = parser.parseQuery(query, null);
List<StatementPattern> spList = StatementPatternCollector.process(pq.getTupleExpr());
StatementMetadataNode<?> node = new StatementMetadataNode<>(spList, conf);
CloseableIteration<BindingSet, QueryEvaluationException> iteration = node.evaluate(new QueryBindingSet());
QueryBindingSet bs = new QueryBindingSet();
bs.addBinding("x", new LiteralImpl("CoffeeShop"));
bs.addBinding("y", new LiteralImpl("Joe"));
List<BindingSet> bsList = new ArrayList<>();
while (iteration.hasNext()) {
bsList.add(iteration.next());
}
Assert.assertEquals(1, bsList.size());
Assert.assertEquals(bs, bsList.get(0));
dao.delete(statement, conf);
} finally {
dao.destroy();
}
}
use of org.openrdf.model.impl.LiteralImpl in project incubator-rya by apache.
the class AccumuloConstantPcjIT method testEvaluateThreeIndexVarInstantiate.
@Test
public void testEvaluateThreeIndexVarInstantiate() 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");
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");
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, obj);
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 ?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 . " + //
" <uri:entity> <uri:howlsAt> ?f. " + //
" ?f <uri:subType> <uri:obj>. " + //
"}";
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());
PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablename + 3, indexSparqlString3, new String[] { "wolf", "sheep", "chicken" }, 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 PCJOptionalTestIT method init.
@Before
public void init() throws RepositoryException, TupleQueryResultHandlerException, QueryEvaluationException, MalformedQueryException, AccumuloException, AccumuloSecurityException, TableExistsException, RyaDAOException, TableNotFoundException, InferenceEngineException, NumberFormatException, UnknownHostException, SailException {
repo = PcjIntegrationTestingUtil.getAccumuloNonPcjRepo(tablePrefix, "instance");
conn = repo.getConnection();
pcjRepo = PcjIntegrationTestingUtil.getAccumuloPcjRepo(tablePrefix, "instance");
pcjConn = pcjRepo.getConnection();
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);
sub2 = new URIImpl("uri:entity2");
subclass2 = new URIImpl("uri:class2");
obj2 = new URIImpl("uri:obj2");
sub3 = new URIImpl("uri:entity3");
subclass3 = new URIImpl("uri:class3");
conn.add(sub2, RDF.TYPE, subclass2);
conn.add(sub2, RDFS.LABEL, new LiteralImpl("label2"));
conn.add(sub2, talksTo, obj2);
conn.add(sub3, RDF.TYPE, subclass3);
conn.add(sub3, RDFS.LABEL, new LiteralImpl("label3"));
accCon = new MockInstance("instance").getConnector("root", new PasswordToken(""));
}
use of org.openrdf.model.impl.LiteralImpl in project incubator-rya by apache.
the class PrecompJoinOptimizerIT method testEvaluateSingeFilterWithLeftJoin.
@Test
public void testEvaluateSingeFilterWithLeftJoin() throws TupleQueryResultHandlerException, QueryEvaluationException, MalformedQueryException, RepositoryException, AccumuloException, AccumuloSecurityException, TableExistsException, RyaDAOException, SailException, TableNotFoundException, PcjException, InferenceEngineException, NumberFormatException, UnknownHostException {
final String indexSparqlString1 = //
"" + //
"SELECT ?e ?l ?c " + //
"{" + //
" Filter(?l = \"label3\") " + //
" ?e a ?c . " + //
" ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l " + //
"}";
final URI sub3 = new URIImpl("uri:entity3");
final URI subclass3 = new URIImpl("uri:class3");
conn.add(sub3, RDF.TYPE, subclass3);
conn.add(sub3, RDFS.LABEL, new LiteralImpl("label3"));
PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablePrefix + "INDEX_1", indexSparqlString1, new String[] { "e", "l", "c" }, Optional.<PcjVarOrderFactory>absent());
final String queryString = //
"" + //
"SELECT ?e ?c ?o ?m ?l" + //
"{" + //
" Filter(?l = \"label3\") " + //
" ?e a ?c . " + //
" ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . " + //
" OPTIONAL { ?e <uri:talksTo> ?o . ?e <http://www.w3.org/2000/01/rdf-schema#label> ?m }" + //
"}";
final CountingResultHandler crh = new CountingResultHandler();
PcjIntegrationTestingUtil.deleteCoreRyaTables(accCon, tablePrefix);
PcjIntegrationTestingUtil.closeAndShutdown(conn, repo);
repo = PcjIntegrationTestingUtil.getAccumuloPcjRepo(tablePrefix, "instance");
conn = repo.getConnection();
conn.add(sub, talksTo, obj);
conn.add(sub, RDFS.LABEL, new LiteralImpl("label"));
pcjConn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh);
Assert.assertEquals(1, crh.getCount());
}
use of org.openrdf.model.impl.LiteralImpl in project incubator-rya by apache.
the class PrecompJoinOptimizerIT method init.
@Before
public void init() throws RepositoryException, TupleQueryResultHandlerException, QueryEvaluationException, MalformedQueryException, AccumuloException, AccumuloSecurityException, TableExistsException, RyaDAOException, TableNotFoundException, InferenceEngineException, NumberFormatException, UnknownHostException, SailException {
repo = PcjIntegrationTestingUtil.getAccumuloNonPcjRepo(tablePrefix, "instance");
conn = repo.getConnection();
pcjRepo = PcjIntegrationTestingUtil.getAccumuloPcjRepo(tablePrefix, "instance");
pcjConn = pcjRepo.getConnection();
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);
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(""));
}
Aggregations