Search in sources :

Example 1 with AccumuloRyaQueryEngine

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);
}
Also used : AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) RyaURI(org.apache.rya.api.domain.RyaURI) AccumuloRyaQueryEngine(org.apache.rya.accumulo.query.AccumuloRyaQueryEngine) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaType(org.apache.rya.api.domain.RyaType) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration)

Example 2 with AccumuloRyaQueryEngine

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();
}
Also used : AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) AccumuloRyaQueryEngine(org.apache.rya.accumulo.query.AccumuloRyaQueryEngine) RyaStatement(org.apache.rya.api.domain.RyaStatement)

Example 3 with AccumuloRyaQueryEngine

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);
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) StatementMetadata(org.apache.rya.api.domain.StatementMetadata) 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)

Example 4 with AccumuloRyaQueryEngine

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);
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) 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)

Example 5 with AccumuloRyaQueryEngine

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();
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) RyaStatement(org.apache.rya.api.domain.RyaStatement) AccumuloRyaQueryEngine(org.apache.rya.accumulo.query.AccumuloRyaQueryEngine) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) RyaType(org.apache.rya.api.domain.RyaType) 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