Search in sources :

Example 1 with CountingResultHandler

use of org.apache.rya.indexing.external.PrecompJoinOptimizerIT.CountingResultHandler in project incubator-rya by apache.

the class PCJOptionalTestIT method testEvaluateSingeIndexExactMatch.

@Test
public void testEvaluateSingeIndexExactMatch() throws TupleQueryResultHandlerException, QueryEvaluationException, MalformedQueryException, RepositoryException, AccumuloException, AccumuloSecurityException, TableExistsException, RyaDAOException, SailException, TableNotFoundException, PcjException, InferenceEngineException {
    final String indexSparqlString = // 
    "" + // 
    "SELECT ?e ?c ?l ?o" + // 
    "{" + // 
    "  ?e a ?c . " + // 
    "  ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l " + // 
    "  OPTIONAL{?e <uri:talksTo> ?o } . " + // 
    "}";
    PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablePrefix + "INDEX_1", indexSparqlString, new String[] { "e", "c", "l", "o" }, Optional.<PcjVarOrderFactory>absent());
    final String queryString = // 
    "" + // 
    "SELECT ?e ?c ?l ?o " + // 
    "{" + // 
    "  ?e a ?c . " + // 
    "  ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . " + // 
    "  OPTIONAL {?e <uri:talksTo> ?o } . " + // 
    "}";
    final CountingResultHandler crh = new CountingResultHandler();
    PcjIntegrationTestingUtil.deleteCoreRyaTables(accCon, tablePrefix);
    PcjIntegrationTestingUtil.closeAndShutdown(conn, repo);
    final TupleQuery tupQuery = pcjConn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
    tupQuery.evaluate(crh);
    Assert.assertEquals(3, crh.getCount());
}
Also used : CountingResultHandler(org.apache.rya.indexing.external.PrecompJoinOptimizerIT.CountingResultHandler) TupleQuery(org.openrdf.query.TupleQuery) Test(org.junit.Test)

Example 2 with CountingResultHandler

use of org.apache.rya.indexing.external.PrecompJoinOptimizerIT.CountingResultHandler in project incubator-rya by apache.

the class PCJOptionalTestIT method testEvaluateSingeIndex.

@Test
public void testEvaluateSingeIndex() throws TupleQueryResultHandlerException, QueryEvaluationException, MalformedQueryException, RepositoryException, AccumuloException, AccumuloSecurityException, TableExistsException, RyaDAOException, SailException, TableNotFoundException, PcjException, InferenceEngineException, NumberFormatException, UnknownHostException {
    final String indexSparqlString = // 
    "" + // 
    "SELECT ?e ?l ?o" + // 
    "{" + // 
    "  ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l " + // 
    "  OPTIONAL{?e <uri:talksTo> ?o } . " + // 
    "}";
    PcjIntegrationTestingUtil.createAndPopulatePcj(conn, accCon, tablePrefix + "INDEX_1", indexSparqlString, new String[] { "e", "l", "o" }, Optional.<PcjVarOrderFactory>absent());
    final String queryString = // 
    "" + // 
    "SELECT ?e ?c ?l ?o " + // 
    "{" + // 
    "  ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . " + // 
    "  OPTIONAL {?e <uri:talksTo> ?o } . " + // 
    "  ?e a ?c . " + // 
    "}";
    final CountingResultHandler crh = new CountingResultHandler();
    PcjIntegrationTestingUtil.deleteCoreRyaTables(accCon, tablePrefix);
    PcjIntegrationTestingUtil.closeAndShutdown(conn, repo);
    repo = PcjIntegrationTestingUtil.getAccumuloPcjRepo(tablePrefix, "instance");
    conn = repo.getConnection();
    conn.add(sub, RDF.TYPE, subclass);
    conn.add(sub2, RDF.TYPE, subclass2);
    conn.add(sub3, RDF.TYPE, subclass3);
    final TupleQuery tupQuery = pcjConn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
    tupQuery.evaluate(crh);
    Assert.assertEquals(3, crh.getCount());
}
Also used : CountingResultHandler(org.apache.rya.indexing.external.PrecompJoinOptimizerIT.CountingResultHandler) TupleQuery(org.openrdf.query.TupleQuery) Test(org.junit.Test)

Aggregations

CountingResultHandler (org.apache.rya.indexing.external.PrecompJoinOptimizerIT.CountingResultHandler)2 Test (org.junit.Test)2 TupleQuery (org.openrdf.query.TupleQuery)2