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);
}
}
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;
}
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;
}
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();
}
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();
}
Aggregations