use of org.apache.rya.api.persist.query.join.MergeJoin in project incubator-rya by apache.
the class MergeJoinTest method testMergeJoinMultiWayNone.
@Test
public void testMergeJoinMultiWayNone() 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
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), new CustomEntry<RyaURI, RyaType>(pred, three), new CustomEntry<RyaURI, RyaType>(pred, four));
assertFalse(join.hasNext());
join.close();
}
use of org.apache.rya.api.persist.query.join.MergeJoin in project incubator-rya by apache.
the class MergeJoinTest method testMergeJoinMultiWay.
@Test
public void testMergeJoinMultiWay() 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, two));
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, 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, 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
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), new CustomEntry<RyaURI, RyaType>(pred, three), new 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(subj4));
join.close();
}
Aggregations