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);
}
Aggregations