use of org.apache.rya.accumulo.query.AccumuloRyaQueryEngine in project incubator-rya by apache.
the class Upgrade322ToolTest method testUpgrade.
public void testUpgrade() throws Exception {
Upgrade322Tool.main(new String[] { "-Dac.mock=true", "-Dac.instance=" + instance, "-Dac.username=" + user, "-Dac.pwd=" + pwd, "-Drdf.tablePrefix=" + tablePrefix });
final AccumuloRdfConfiguration configuration = new AccumuloRdfConfiguration();
configuration.setTablePrefix(tablePrefix);
final AccumuloRyaDAO ryaDAO = new AccumuloRyaDAO();
ryaDAO.setConnector(connector);
ryaDAO.setConf(configuration);
ryaDAO.init();
final AccumuloRyaQueryEngine queryEngine = ryaDAO.getQueryEngine();
TestUtils.verify(new RyaStatement(new RyaURI("http://here/2010/tracked-data-provenance/ns#uuid10"), new RyaURI("http://here/2010/tracked-data-provenance/ns#booleanLit"), new RyaType(XMLSchema.BOOLEAN, "true")), queryEngine);
TestUtils.verify(new RyaStatement(new RyaURI("http://here/2010/tracked-data-provenance/ns#uuid10"), new RyaURI("http://here/2010/tracked-data-provenance/ns#longLit"), new RyaType(XMLSchema.LONG, "10")), queryEngine);
TestUtils.verify(new RyaStatement(new RyaURI("http://here/2010/tracked-data-provenance/ns#uuid10"), new RyaURI("http://here/2010/tracked-data-provenance/ns#intLit"), new RyaType(XMLSchema.INTEGER, "10")), queryEngine);
TestUtils.verify(new RyaStatement(new RyaURI("http://here/2010/tracked-data-provenance/ns#uuid10"), new RyaURI("http://here/2010/tracked-data-provenance/ns#byteLit"), new RyaType(XMLSchema.BYTE, "10")), queryEngine);
TestUtils.verify(new RyaStatement(new RyaURI("http://here/2010/tracked-data-provenance/ns#uuid10"), new RyaURI("http://here/2010/tracked-data-provenance/ns#doubleLit"), new RyaType(XMLSchema.DOUBLE, "10.0")), queryEngine);
TestUtils.verify(new RyaStatement(new RyaURI("http://here/2010/tracked-data-provenance/ns#uuid10"), new RyaURI("http://here/2010/tracked-data-provenance/ns#dateLit"), new RyaType(XMLSchema.DATETIME, "2011-07-12T06:00:00.000Z")), queryEngine);
TestUtils.verify(new RyaStatement(new RyaURI("http://here/2010/tracked-data-provenance/ns#uuid10"), new RyaURI("http://here/2010/tracked-data-provenance/ns#stringLit"), new RyaType("stringLit")), queryEngine);
TestUtils.verify(new RyaStatement(new RyaURI("http://here/2010/tracked-data-provenance/ns#uuid10"), new RyaURI("http://here/2010/tracked-data-provenance/ns#uriLit"), new RyaURI("http://here/2010/tracked-data-provenance/ns" + "#objectuuid1")), queryEngine);
TestUtils.verify(new RyaStatement(new RyaURI("urn:org.apache.rya/2012/05#rts"), new RyaURI("urn:org.apache.rya/2012/05#version"), new RyaType("3.0.0")), queryEngine);
}
use of org.apache.rya.accumulo.query.AccumuloRyaQueryEngine in project incubator-rya by apache.
the class TestUtils method verify.
public static void verify(Connector connector, AccumuloRdfConfiguration conf, RyaStatement... ryaStatements) throws RyaDAOException, IOException {
AccumuloRyaDAO dao = new AccumuloRyaDAO();
dao.setConnector(connector);
dao.setConf(conf);
dao.init();
AccumuloRyaQueryEngine engine = dao.getQueryEngine();
for (RyaStatement ryaStatement : ryaStatements) {
verify(ryaStatement, engine);
}
dao.destroy();
}
use of org.apache.rya.accumulo.query.AccumuloRyaQueryEngine in project incubator-rya by apache.
the class AccumuloRyaDAOTest method testAddCv.
@Test
public void testAddCv() throws Exception {
RyaURI cpu = new RyaURI(litdupsNS + "cpu");
RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
RyaURI uri1 = new RyaURI(litdupsNS + "uri1");
RyaURI uri2 = new RyaURI(litdupsNS + "uri2");
RyaURI uri3 = new RyaURI(litdupsNS + "uri3");
byte[] colVisABC = "A|B|C".getBytes();
byte[] colVisAB = "A|B".getBytes();
byte[] colVisA = "A".getBytes();
dao.add(new RyaStatement(cpu, loadPerc, uri1, null, null, new StatementMetadata(), colVisABC));
dao.add(new RyaStatement(cpu, loadPerc, uri2, null, null, new StatementMetadata(), colVisAB));
dao.add(new RyaStatement(cpu, loadPerc, uri3, null, null, new StatementMetadata(), colVisA));
AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
// query with no auth
CloseableIteration<RyaStatement, RyaDAOException> iter = queryEngine.query(new RyaStatement(cpu, loadPerc, null), conf);
int count = 0;
while (iter.hasNext()) {
count++;
iter.next();
}
assertEquals(0, count);
iter.close();
AccumuloRdfConfiguration queryConf = new AccumuloRdfConfiguration();
queryConf.setAuth("B");
iter = queryEngine.query(new RyaStatement(cpu, loadPerc, null), queryConf);
count = 0;
while (iter.hasNext()) {
iter.next();
count++;
}
iter.close();
assertEquals(2, count);
queryConf.setAuth("A");
iter = queryEngine.query(new RyaStatement(cpu, loadPerc, null), queryConf);
count = 0;
while (iter.hasNext()) {
iter.next();
count++;
}
iter.close();
assertEquals(3, count);
}
use of org.apache.rya.accumulo.query.AccumuloRyaQueryEngine in project incubator-rya by apache.
the class AccumuloRyaDAOTest method testTTL.
@Test
public void testTTL() throws Exception {
RyaURI cpu = new RyaURI(litdupsNS + "cpu");
RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
long current = System.currentTimeMillis();
dao.add(new RyaStatement(cpu, loadPerc, new RyaURI(litdupsNS + "uri1"), null, null, null, null, current));
dao.add(new RyaStatement(cpu, loadPerc, new RyaURI(litdupsNS + "uri2"), null, null, null, null, current - 1010l));
dao.add(new RyaStatement(cpu, loadPerc, new RyaURI(litdupsNS + "uri3"), null, null, null, null, current - 2010l));
dao.add(new RyaStatement(cpu, loadPerc, new RyaURI(litdupsNS + "uri4"), null, null, null, null, current - 3010l));
dao.add(new RyaStatement(cpu, loadPerc, new RyaURI(litdupsNS + "uri5"), null, null, null, null, current - 4010l));
AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
AccumuloRdfConfiguration queryConf = conf.clone();
queryConf.setTtl(3000l);
CloseableIteration<RyaStatement, RyaDAOException> iter = queryEngine.query(new RyaStatement(cpu, loadPerc, null), queryConf);
int count = 0;
while (iter.hasNext()) {
iter.next().getObject();
count++;
}
iter.close();
assertEquals(3, count);
queryConf.setStartTime(current - 3000l);
iter = queryEngine.query(new RyaStatement(cpu, loadPerc, null), queryConf);
count = 0;
while (iter.hasNext()) {
iter.next().getObject();
count++;
}
iter.close();
assertEquals(2, count);
}
use of org.apache.rya.accumulo.query.AccumuloRyaQueryEngine in project incubator-rya by apache.
the class AccumuloRyaDAOTest method testLiteralTypes.
@Test
public void testLiteralTypes() throws Exception {
RyaURI cpu = new RyaURI(litdupsNS + "cpu");
RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
RyaType longLit = new RyaType(XMLSchema.LONG, "3");
dao.add(new RyaStatement(cpu, loadPerc, longLit));
AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
CloseableIteration<RyaStatement, RyaDAOException> query = queryEngine.query(new RyaStatement(cpu, null, null), conf);
assertTrue(query.hasNext());
RyaStatement next = query.next();
assertEquals(new Long(longLit.getData()), new Long(next.getObject().getData()));
query.close();
RyaType doubleLit = new RyaType(XMLSchema.DOUBLE, "2.0");
dao.add(new RyaStatement(cpu, loadPerc, doubleLit));
query = queryEngine.query(new RyaStatement(cpu, loadPerc, doubleLit), conf);
assertTrue(query.hasNext());
next = query.next();
assertEquals(Double.parseDouble(doubleLit.getData()), Double.parseDouble(next.getObject().getData()), 0.001);
query.close();
}
Aggregations