Search in sources :

Example 46 with RyaDAOException

use of org.apache.rya.api.persist.RyaDAOException 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 47 with RyaDAOException

use of org.apache.rya.api.persist.RyaDAOException 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 48 with RyaDAOException

use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.

the class AccumuloRyaDAOTest method testAdd.

@Test
public void testAdd() throws Exception {
    RyaURI cpu = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "cpu"));
    RyaURI loadPerc = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "loadPerc"));
    RyaURI uri1 = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "uri1"));
    dao.add(new RyaStatement(cpu, loadPerc, uri1));
    CloseableIteration<RyaStatement, RyaDAOException> iter = dao.getQueryEngine().query(new RyaStatement(cpu, loadPerc, null), conf);
    int count = 0;
    while (iter.hasNext()) {
        assertTrue(uri1.equals(iter.next().getObject()));
        count++;
    }
    iter.close();
    assertEquals(1, count);
    dao.delete(new RyaStatement(cpu, loadPerc, null), conf);
    iter = dao.getQueryEngine().query(new RyaStatement(cpu, loadPerc, null), conf);
    count = 0;
    while (iter.hasNext()) {
        count++;
        iter.next();
    }
    iter.close();
    assertEquals(0, count);
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) Test(org.junit.Test)

Example 49 with RyaDAOException

use of org.apache.rya.api.persist.RyaDAOException 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)

Example 50 with RyaDAOException

use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.

the class AccumuloRyaDAOTest method testQueryCollectionRegex.

@Test
public void testQueryCollectionRegex() 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");
    RyaURI uri4 = new RyaURI(litdupsNS + "uri4");
    RyaURI uri5 = new RyaURI(litdupsNS + "uri5");
    RyaURI uri6 = new RyaURI(litdupsNS + "uri6");
    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));
    AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
    Collection<RyaStatement> coll = new ArrayList();
    coll.add(new RyaStatement(null, loadPerc, uri1));
    coll.add(new RyaStatement(null, loadPerc, uri2));
    conf.setRegexPredicate(loadPerc.getData());
    CloseableIteration<RyaStatement, RyaDAOException> iter = queryEngine.batchQuery(coll, conf);
    int count = 0;
    while (iter.hasNext()) {
        count++;
        iter.next();
    }
    iter.close();
    assertEquals(2, count);
    conf.setRegexPredicate("notLoadPerc");
    iter = queryEngine.batchQuery(coll, conf);
    count = 0;
    while (iter.hasNext()) {
        count++;
        iter.next();
    }
    iter.close();
    assertEquals(0, count);
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) 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

RyaDAOException (org.apache.rya.api.persist.RyaDAOException)100 RyaStatement (org.apache.rya.api.domain.RyaStatement)61 RyaURI (org.apache.rya.api.domain.RyaURI)45 Test (org.junit.Test)39 RyaType (org.apache.rya.api.domain.RyaType)28 IOException (java.io.IOException)26 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)23 AccumuloException (org.apache.accumulo.core.client.AccumuloException)22 SailException (org.openrdf.sail.SailException)15 HashSet (java.util.HashSet)12 AccumuloRyaQueryEngine (org.apache.rya.accumulo.query.AccumuloRyaQueryEngine)12 RdfCloudTripleStoreUtils (org.apache.rya.api.RdfCloudTripleStoreUtils)12 Map (java.util.Map)11 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)11 RyaClientException (org.apache.rya.api.client.RyaClientException)11 MutationsRejectedException (org.apache.accumulo.core.client.MutationsRejectedException)10 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)10 ArrayList (java.util.ArrayList)9 Scanner (org.apache.accumulo.core.client.Scanner)8 Text (org.apache.hadoop.io.Text)8