Search in sources :

Example 16 with AccumuloRyaQueryEngine

use of org.apache.rya.accumulo.query.AccumuloRyaQueryEngine in project incubator-rya by apache.

the class AccumuloRyaDAOTest method testQueryWithIterators.

@Test
public void testQueryWithIterators() throws Exception {
    RyaURI cpu = new RyaURI(litdupsNS + "cpu");
    RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
    RyaURI uri1 = new RyaURI(litdupsNS + "uri1");
    dao.add(new RyaStatement(cpu, loadPerc, uri1, null, "qual1"));
    dao.add(new RyaStatement(cpu, loadPerc, uri1, null, "qual2"));
    AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
    AccumuloRdfConfiguration queryConf = new AccumuloRdfConfiguration(conf);
    IteratorSetting firstEntryInRow = new IteratorSetting(3, /* correct value?? */
    FirstEntryInRowIterator.class);
    queryConf.setAdditionalIterators(firstEntryInRow);
    Collection<RyaStatement> coll = new ArrayList<>();
    coll.add(new RyaStatement(null, loadPerc, uri1));
    CloseableIteration<RyaStatement, RyaDAOException> iter = queryEngine.batchQuery(coll, queryConf);
    int count = 0;
    while (iter.hasNext()) {
        count++;
        iter.next();
    }
    iter.close();
    assertEquals(1, count);
    // Assert that without the iterator we get 2
    coll = new ArrayList<>();
    coll.add(new RyaStatement(null, loadPerc, uri1));
    iter = queryEngine.batchQuery(coll, conf);
    count = 0;
    while (iter.hasNext()) {
        count++;
        iter.next();
    }
    iter.close();
    assertEquals(2, count);
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) ArrayList(java.util.ArrayList) RyaStatement(org.apache.rya.api.domain.RyaStatement) AccumuloRyaQueryEngine(org.apache.rya.accumulo.query.AccumuloRyaQueryEngine) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) Test(org.junit.Test)

Aggregations

AccumuloRyaQueryEngine (org.apache.rya.accumulo.query.AccumuloRyaQueryEngine)16 RyaStatement (org.apache.rya.api.domain.RyaStatement)14 RyaURI (org.apache.rya.api.domain.RyaURI)12 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)12 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)5 RyaType (org.apache.rya.api.domain.RyaType)4 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)3 IOException (java.io.IOException)2 AccumuloException (org.apache.accumulo.core.client.AccumuloException)2 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)2 AccumuloRyaDAO (org.apache.rya.accumulo.AccumuloRyaDAO)2 HashSet (java.util.HashSet)1 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)1 Connector (org.apache.accumulo.core.client.Connector)1 Instance (org.apache.accumulo.core.client.Instance)1 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)1 MutationsRejectedException (org.apache.accumulo.core.client.MutationsRejectedException)1 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)1 ZooKeeperInstance (org.apache.accumulo.core.client.ZooKeeperInstance)1