use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.
the class AccumuloRyaDAOTest method testSameLiteralStringTypes.
@Test
public void testSameLiteralStringTypes() throws Exception {
RyaURI cpu = new RyaURI(litdupsNS + "cpu");
RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
RyaType longLit = new RyaType(XMLSchema.LONG, "10");
RyaType strLit = new RyaType(XMLSchema.STRING, new String(RyaContext.getInstance().serializeType(longLit)[0]));
RyaStatement expected = new RyaStatement(cpu, loadPerc, longLit);
dao.add(expected);
dao.add(new RyaStatement(cpu, loadPerc, strLit));
AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
CloseableIteration<RyaStatement, RyaDAOException> query = queryEngine.query(new RyaStatement(cpu, loadPerc, longLit), conf);
assertTrue(query.hasNext());
RyaStatement next = query.next();
assertEquals(new Long(longLit.getData()), new Long(next.getObject().getData()));
assertEquals(longLit.getDataType(), next.getObject().getDataType());
assertFalse(query.hasNext());
query.close();
}
use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.
the class AccumuloRyaDAOTest method testQueryDates.
@Test
public void testQueryDates() throws Exception {
RyaURI cpu = new RyaURI(litdupsNS + "cpu");
RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
// How handles local time
RyaType uri0 = new RyaType(XMLSchema.DATETIME, "1960-01-01");
// See Magadan Time
RyaType uri1 = new RyaType(XMLSchema.DATETIME, "1992-01-01T+10:00");
// How it handles UTC.
RyaType uri2 = new RyaType(XMLSchema.DATETIME, "2000-01-01TZ");
RyaType uri3 = new RyaType(XMLSchema.DATETIME, "2000-01-01T00:00:01.111Z");
// duplicate
RyaType uri4 = new RyaType(XMLSchema.DATETIME, "2000-01-01T00:00:01.111Z");
RyaType uri5 = new RyaType(XMLSchema.DATETIME, "2000-01-01T00:00:01-00:00");
// duplicate
RyaType uri6 = new RyaType(XMLSchema.DATETIME, "2000-01-01T00:00:01Z");
RyaType uri7 = new RyaType(XMLSchema.DATETIME, "-2000-01-01T00:00:01Z");
RyaType uri8 = new RyaType(XMLSchema.DATETIME, "111-01-01T00:00:01Z");
RyaType uri9 = new RyaType(XMLSchema.DATETIME, "12345-01-01T00:00:01Z");
dao.add(new RyaStatement(cpu, loadPerc, uri0));
dao.add(new RyaStatement(cpu, loadPerc, uri1));
dao.add(new RyaStatement(cpu, loadPerc, uri2));
dao.add(new RyaStatement(cpu, loadPerc, uri3));
dao.add(new RyaStatement(cpu, loadPerc, uri4));
dao.add(new RyaStatement(cpu, loadPerc, uri5));
dao.add(new RyaStatement(cpu, loadPerc, uri6));
dao.add(new RyaStatement(cpu, loadPerc, uri7));
dao.add(new RyaStatement(cpu, loadPerc, uri8));
dao.add(new RyaStatement(cpu, loadPerc, uri9));
AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
Collection<RyaStatement> coll = new ArrayList();
coll.add(new RyaStatement(null, loadPerc, uri0));
coll.add(new RyaStatement(null, loadPerc, uri1));
coll.add(new RyaStatement(null, loadPerc, uri2));
CloseableIteration<RyaStatement, RyaDAOException> iter = queryEngine.batchQuery(coll, conf);
int count = 0;
while (iter.hasNext()) {
count++;
iter.next();
}
iter.close();
assertEquals("Three time zones should be normalized when stored, then normalized same when queried.", 3, count);
// now use batchscanner
AccumuloRdfConfiguration queryConf = new AccumuloRdfConfiguration(conf);
queryConf.setMaxRangesForScanner(2);
coll = new ArrayList();
coll.add(new RyaStatement(null, loadPerc, uri0));
coll.add(new RyaStatement(null, loadPerc, uri1));
coll.add(new RyaStatement(null, loadPerc, uri2));
coll.add(new RyaStatement(null, loadPerc, uri3));
coll.add(new RyaStatement(null, loadPerc, uri4));
coll.add(new RyaStatement(null, loadPerc, uri5));
coll.add(new RyaStatement(null, loadPerc, uri6));
coll.add(new RyaStatement(null, loadPerc, uri7));
coll.add(new RyaStatement(null, loadPerc, uri8));
coll.add(new RyaStatement(null, loadPerc, uri9));
iter = queryEngine.batchQuery(coll, queryConf);
count = 0;
while (iter.hasNext()) {
count++;
iter.next();
}
iter.close();
assertEquals("Variety of time specs, including BC, pre-1970, duplicate pair ovewrite,future, 3 digit year.", 8, count);
}
use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.
the class AccumuloRyaDAOTest method testAddValue.
@Test
public void testAddValue() throws Exception {
RyaURI cpu = new RyaURI(litdupsNS + "cpu");
RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
RyaURI uri1 = new RyaURI(litdupsNS + "uri1");
String myval = "myval";
byte[] columnVis = null;
dao.add(new RyaStatement(cpu, loadPerc, uri1, null, null, columnVis, myval.getBytes()));
AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
CloseableIteration<RyaStatement, RyaDAOException> iter = queryEngine.query(new RyaStatement(cpu, loadPerc, null), conf);
assertTrue(iter.hasNext());
assertEquals(myval, new String(iter.next().getValue()));
iter.close();
}
use of org.apache.rya.api.persist.RyaDAOException 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);
}
use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.
the class MongoDBQueryEngine method queryWithBindingSet.
@Override
public CloseableIteration<? extends Entry<RyaStatement, BindingSet>, RyaDAOException> queryWithBindingSet(final Collection<Entry<RyaStatement, BindingSet>> stmts, final StatefulMongoDBRdfConfiguration conf) throws RyaDAOException {
checkNotNull(stmts);
checkNotNull(conf);
final Multimap<RyaStatement, BindingSet> rangeMap = HashMultimap.create();
// TODO: cannot span multiple tables here
try {
for (final Map.Entry<RyaStatement, BindingSet> stmtbs : stmts) {
final RyaStatement stmt = stmtbs.getKey();
final BindingSet bs = stmtbs.getValue();
rangeMap.put(stmt, bs);
}
// TODO not sure what to do about regex ranges?
final RyaStatementBindingSetCursorIterator iterator = new RyaStatementBindingSetCursorIterator(getCollection(conf), rangeMap, strategy, conf.getAuthorizations());
return iterator;
} catch (final Exception e) {
throw new RyaDAOException(e);
}
}
Aggregations