use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.
the class RowRuleMapper method copyStatement.
/**
* Add a statement to an in-memory Accumulo instance, serialized as spo/pos/osp and any applicable secondary
* indexes, and flush the in-memory rows through to the output if enough statements have been cached.
* @param rstmt RyaStatement to copy to the child
* @param context Context to use for writing
* @throws InterruptedException if Hadoop is interrupted while writing output.
* @throws IOException if an error is encountered serializing and storing the statement in memory, or
* if Hadoop reports an error writing the in-memory tables to the output.
*/
@Override
protected void copyStatement(final RyaStatement rstmt, final Context context) throws IOException, InterruptedException {
try {
childDao.add(rstmt);
cachedStatements++;
} catch (final RyaDAOException e) {
throw new IOException("Error serializing RyaStatement", e);
}
if (cachedStatements >= maxStatements) {
flush(context);
}
}
use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.
the class StatementMetadataNode method evaluate.
/**
* This method pairs each {@link BindingSet} in the specified collection
* with the StatementPattern constraints and issues a query to Rya using the
* {@link RyaQueryEngine}.
*/
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Collection<BindingSet> bindingset) throws QueryEvaluationException {
if (bindingset.size() == 0) {
return new EmptyIteration<>();
}
queryEngine = RyaQueryEngineFactory.getQueryEngine(conf);
Set<Map.Entry<RyaStatement, BindingSet>> statements = new HashSet<>();
Iterator<BindingSet> iter = bindingset.iterator();
while (iter.hasNext()) {
BindingSet bs = iter.next();
statements.add(new RdfCloudTripleStoreUtils.CustomEntry<RyaStatement, BindingSet>(getRyaStatementFromBindings(bs), bs));
}
final CloseableIteration<? extends Entry<RyaStatement, BindingSet>, RyaDAOException> iteration;
try {
iteration = queryEngine.queryWithBindingSet(statements, conf);
} catch (RyaDAOException e) {
throw new RuntimeException(e);
}
return new PropertyFilterAndBindingSetJoinIteration(iteration, properties, statement);
}
use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.
the class IterativeJoinTest method testSimpleIterativeJoinMultiWay.
@Test
public void testSimpleIterativeJoinMultiWay() throws Exception {
// add data
RyaURI pred = new RyaURI(litdupsNS, "pred1");
RyaType one = new RyaType("1");
RyaType two = new RyaType("2");
RyaType three = new RyaType("3");
RyaType four = new RyaType("4");
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(subj1, pred, three));
dao.add(new RyaStatement(subj1, pred, four));
dao.add(new RyaStatement(subj2, pred, one));
dao.add(new RyaStatement(subj2, pred, two));
dao.add(new RyaStatement(subj2, pred, three));
dao.add(new RyaStatement(subj2, pred, four));
dao.add(new RyaStatement(subj3, pred, one));
dao.add(new RyaStatement(subj3, pred, two));
dao.add(new RyaStatement(subj3, pred, three));
dao.add(new RyaStatement(subj3, pred, four));
dao.add(new RyaStatement(subj4, pred, one));
dao.add(new RyaStatement(subj4, pred, two));
dao.add(new RyaStatement(subj4, pred, three));
dao.add(new RyaStatement(subj4, pred, four));
// 1 join
IterativeJoin iterativeJoin = new IterativeJoin(dao.getQueryEngine());
CloseableIteration<RyaURI, RyaDAOException> join = iterativeJoin.join(null, new RdfCloudTripleStoreUtils.CustomEntry<RyaURI, RyaType>(pred, one), new RdfCloudTripleStoreUtils.CustomEntry<RyaURI, RyaType>(pred, two), new RdfCloudTripleStoreUtils.CustomEntry<RyaURI, RyaType>(pred, three), new RdfCloudTripleStoreUtils.CustomEntry<RyaURI, RyaType>(pred, four));
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();
}
use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.
the class IterativeJoinTest method testSimpleIterativeJoinPredicateOnly.
@Test
public void testSimpleIterativeJoinPredicateOnly() 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
IterativeJoin ijoin = new IterativeJoin(dao.getQueryEngine());
CloseableIteration<RyaStatement, RyaDAOException> join = ijoin.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 IterativeJoinTest method testIterativeJoinMultiWayNone.
@Test
public void testIterativeJoinMultiWayNone() throws Exception {
// add data
RyaURI pred = new RyaURI(litdupsNS, "pred1");
RyaType zero = new RyaType("0");
RyaType one = new RyaType("1");
RyaType two = new RyaType("2");
RyaType three = new RyaType("3");
RyaType four = new RyaType("4");
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, three));
dao.add(new RyaStatement(subj1, pred, four));
dao.add(new RyaStatement(subj2, pred, zero));
dao.add(new RyaStatement(subj2, pred, one));
dao.add(new RyaStatement(subj2, pred, four));
dao.add(new RyaStatement(subj3, pred, two));
dao.add(new RyaStatement(subj3, pred, four));
dao.add(new RyaStatement(subj4, pred, one));
dao.add(new RyaStatement(subj4, pred, two));
dao.add(new RyaStatement(subj4, pred, three));
// 1 join
IterativeJoin iterativeJoin = new IterativeJoin(dao.getQueryEngine());
CloseableIteration<RyaURI, RyaDAOException> join = iterativeJoin.join(null, new RdfCloudTripleStoreUtils.CustomEntry<RyaURI, RyaType>(pred, one), new RdfCloudTripleStoreUtils.CustomEntry<RyaURI, RyaType>(pred, two), new RdfCloudTripleStoreUtils.CustomEntry<RyaURI, RyaType>(pred, three), new RdfCloudTripleStoreUtils.CustomEntry<RyaURI, RyaType>(pred, four));
assertFalse(join.hasNext());
join.close();
}
Aggregations