Search in sources :

Example 96 with RyaDAOException

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();
}
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 97 with RyaDAOException

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);
}
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) RyaType(org.apache.rya.api.domain.RyaType) Test(org.junit.Test)

Example 98 with RyaDAOException

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();
}
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 99 with RyaDAOException

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

Example 100 with RyaDAOException

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);
    }
}
Also used : MapBindingSet(org.openrdf.query.impl.MapBindingSet) BindingSet(org.openrdf.query.BindingSet) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) HashMap(java.util.HashMap) Map(java.util.Map) AbstractMap(java.util.AbstractMap) RyaStatementBindingSetCursorIterator(org.apache.rya.mongodb.iter.RyaStatementBindingSetCursorIterator) IOException(java.io.IOException) RyaDAOException(org.apache.rya.api.persist.RyaDAOException)

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