Search in sources :

Example 16 with RyaDAOException

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

the class RowRuleMapper method addMetadataKeys.

/**
 * Insert copy tool metadata, if the in-memory instance has been configured.
 */
@Override
protected void addMetadataKeys(final Context context) throws IOException {
    try {
        if (childDao != null && childDao.isInitialized()) {
            if (runTime != null) {
                final RyaStatement ryaStatement = AccumuloRyaUtils.createCopyToolRunTimeRyaStatement(runTime);
                copyStatement(ryaStatement, context);
            }
            if (startTime != null) {
                final RyaStatement ryaStatement = AccumuloRyaUtils.createCopyToolSplitTimeRyaStatement(startTime);
                copyStatement(ryaStatement, context);
            }
            if (timeOffset != null) {
                final RyaStatement ryaStatement = AccumuloRyaUtils.createTimeOffsetRyaStatement(timeOffset);
                copyStatement(ryaStatement, context);
            }
        }
    } catch (RyaDAOException | IOException | InterruptedException e) {
        throw new IOException("Failed to write metadata key", e);
    }
}
Also used : RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) IOException(java.io.IOException)

Example 17 with RyaDAOException

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

the class AccumuloRyaUtils method getMetadata.

/**
 * Gets the metadata key from the table.
 * @param ryaStatement the {@link RyaStatement} for the metadata key to query.
 * @param dao the {@link AccumuloRyaDAO}.
 * @return the string value of the object from the metadata key.
 * @throws RyaDAOException
 */
private static String getMetadata(final RyaStatement ryaStatement, final AccumuloRyaDAO dao) throws RyaDAOException {
    String metadata = null;
    final AccumuloRdfConfiguration config = dao.getConf();
    final CloseableIteration<RyaStatement, RyaDAOException> iter = dao.getQueryEngine().query(ryaStatement, config);
    if (iter.hasNext()) {
        metadata = iter.next().getObject().getData();
    }
    iter.close();
    return metadata;
}
Also used : RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration)

Example 18 with RyaDAOException

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

the class AccumuloRyaUtils method setupDao.

/**
 * Sets up a {@link AccumuloRyaDAO} with the specified connector and config.
 * @param connector the {@link Connector}.
 * @param accumuloRdfConfiguration the {@link AccumuloRdfConfiguration}.
 * @return the {@link AccumuloRyaDAO}.
 */
public static AccumuloRyaDAO setupDao(final Connector connector, final AccumuloRdfConfiguration accumuloRdfConfiguration) {
    final AccumuloRyaDAO accumuloRyaDao = new AccumuloRyaDAO();
    accumuloRyaDao.setConnector(connector);
    accumuloRyaDao.setConf(accumuloRdfConfiguration);
    try {
        accumuloRyaDao.init();
    } catch (final RyaDAOException e) {
        log.error("Error initializing DAO", e);
    }
    return accumuloRyaDao;
}
Also used : AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) RyaDAOException(org.apache.rya.api.persist.RyaDAOException)

Example 19 with RyaDAOException

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

the class MergeJoinTest method testSimpleMergeJoinPredicateOnly.

@Test
public void testSimpleMergeJoinPredicateOnly() throws Exception {
    // add data
    RyaURI pred1 = new RyaURI(litdupsNS, "pred1");
    RyaURI pred2 = new RyaURI(litdupsNS, "pred2");
    RyaType one = new RyaType("1");
    RyaURI subj1 = new RyaURI(litdupsNS, "subj1");
    RyaURI subj2 = new RyaURI(litdupsNS, "subj2");
    RyaURI subj3 = new RyaURI(litdupsNS, "subj3");
    RyaURI subj4 = new RyaURI(litdupsNS, "subj4");
    dao.add(new RyaStatement(subj1, pred1, one));
    dao.add(new RyaStatement(subj1, pred2, one));
    dao.add(new RyaStatement(subj2, pred1, one));
    dao.add(new RyaStatement(subj2, pred2, one));
    dao.add(new RyaStatement(subj3, pred1, one));
    dao.add(new RyaStatement(subj3, pred2, one));
    dao.add(new RyaStatement(subj4, pred1, one));
    dao.add(new RyaStatement(subj4, pred2, one));
    // 1 join
    MergeJoin mergeJoin = new MergeJoin(dao.getQueryEngine());
    CloseableIteration<RyaStatement, RyaDAOException> join = mergeJoin.join(null, pred1, pred2);
    int count = 0;
    while (join.hasNext()) {
        RyaStatement next = join.next();
        count++;
    }
    assertEquals(4, count);
    join.close();
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) MergeJoin(org.apache.rya.api.persist.query.join.MergeJoin) RyaType(org.apache.rya.api.domain.RyaType) Test(org.junit.Test)

Example 20 with RyaDAOException

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

the class MergeJoinTest method testSimpleMergeJoin.

@Test
public void testSimpleMergeJoin() throws Exception {
    // add data
    RyaURI pred = new RyaURI(litdupsNS, "pred1");
    RyaType one = new RyaType("1");
    RyaType two = new RyaType("2");
    RyaURI subj1 = new RyaURI(litdupsNS, "subj1");
    RyaURI subj2 = new RyaURI(litdupsNS, "subj2");
    RyaURI subj3 = new RyaURI(litdupsNS, "subj3");
    RyaURI subj4 = new RyaURI(litdupsNS, "subj4");
    dao.add(new RyaStatement(subj1, pred, one));
    dao.add(new RyaStatement(subj1, pred, two));
    dao.add(new RyaStatement(subj2, pred, one));
    dao.add(new RyaStatement(subj2, pred, two));
    dao.add(new RyaStatement(subj3, pred, one));
    dao.add(new RyaStatement(subj3, pred, two));
    dao.add(new RyaStatement(subj4, pred, one));
    dao.add(new RyaStatement(subj4, pred, two));
    // 1 join
    MergeJoin mergeJoin = new MergeJoin(dao.getQueryEngine());
    CloseableIteration<RyaURI, RyaDAOException> join = mergeJoin.join(null, new CustomEntry<RyaURI, RyaType>(pred, one), new CustomEntry<RyaURI, RyaType>(pred, two));
    Set<RyaURI> uris = new HashSet<RyaURI>();
    while (join.hasNext()) {
        uris.add(join.next());
    }
    assertTrue(uris.contains(subj1));
    assertTrue(uris.contains(subj2));
    assertTrue(uris.contains(subj3));
    assertTrue(uris.contains(subj4));
    join.close();
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) MergeJoin(org.apache.rya.api.persist.query.join.MergeJoin) RyaType(org.apache.rya.api.domain.RyaType) HashSet(java.util.HashSet) 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