Search in sources :

Example 1 with HashJoin

use of org.apache.rya.api.persist.query.join.HashJoin in project incubator-rya by apache.

the class HashJoinTest method testMergeJoinMultiWayNone2.

@Test
public void testMergeJoinMultiWayNone2() 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, 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));
    // 1 join
    HashJoin hjoin = new HashJoin(dao.getQueryEngine());
    CloseableIteration<RyaURI, RyaDAOException> join = hjoin.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();
}
Also used : RdfCloudTripleStoreUtils(org.apache.rya.api.RdfCloudTripleStoreUtils) RyaURI(org.apache.rya.api.domain.RyaURI) HashJoin(org.apache.rya.api.persist.query.join.HashJoin) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) RyaType(org.apache.rya.api.domain.RyaType) Test(org.junit.Test)

Example 2 with HashJoin

use of org.apache.rya.api.persist.query.join.HashJoin in project incubator-rya by apache.

the class HashJoinTest method testSimpleMergeJoinPredicateOnly2.

@Test
public void testSimpleMergeJoinPredicateOnly2() throws Exception {
    // add data
    RyaURI pred1 = new RyaURI(litdupsNS, "pred1");
    RyaURI pred2 = new RyaURI(litdupsNS, "pred2");
    RyaType one = new RyaType("1");
    RyaType two = new RyaType("2");
    RyaType three = new RyaType("3");
    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, pred1, two));
    dao.add(new RyaStatement(subj1, pred1, three));
    dao.add(new RyaStatement(subj1, pred2, one));
    dao.add(new RyaStatement(subj1, pred2, two));
    dao.add(new RyaStatement(subj1, pred2, three));
    dao.add(new RyaStatement(subj2, pred1, one));
    dao.add(new RyaStatement(subj2, pred1, two));
    dao.add(new RyaStatement(subj2, pred1, three));
    dao.add(new RyaStatement(subj2, pred2, one));
    dao.add(new RyaStatement(subj2, pred2, two));
    dao.add(new RyaStatement(subj2, pred2, three));
    dao.add(new RyaStatement(subj3, pred1, one));
    dao.add(new RyaStatement(subj3, pred1, two));
    dao.add(new RyaStatement(subj3, pred1, three));
    dao.add(new RyaStatement(subj3, pred2, one));
    dao.add(new RyaStatement(subj3, pred2, two));
    dao.add(new RyaStatement(subj3, pred2, three));
    dao.add(new RyaStatement(subj4, pred1, one));
    dao.add(new RyaStatement(subj4, pred1, two));
    dao.add(new RyaStatement(subj4, pred1, three));
    dao.add(new RyaStatement(subj4, pred2, one));
    dao.add(new RyaStatement(subj4, pred2, two));
    dao.add(new RyaStatement(subj4, pred2, three));
    // 1 join
    HashJoin ijoin = new HashJoin(dao.getQueryEngine());
    CloseableIteration<RyaStatement, RyaDAOException> join = ijoin.join(null, pred1, pred2);
    int count = 0;
    while (join.hasNext()) {
        RyaStatement next = join.next();
        count++;
    }
    assertEquals(12, count);
    join.close();
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) HashJoin(org.apache.rya.api.persist.query.join.HashJoin) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) RyaType(org.apache.rya.api.domain.RyaType) Test(org.junit.Test)

Example 3 with HashJoin

use of org.apache.rya.api.persist.query.join.HashJoin in project incubator-rya by apache.

the class HashJoinTest method testSimpleJoin.

@Test
public void testSimpleJoin() 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
    HashJoin hjoin = new HashJoin(dao.getQueryEngine());
    CloseableIteration<RyaURI, RyaDAOException> join = hjoin.join(null, new RdfCloudTripleStoreUtils.CustomEntry<RyaURI, RyaType>(pred, one), new RdfCloudTripleStoreUtils.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 : RdfCloudTripleStoreUtils(org.apache.rya.api.RdfCloudTripleStoreUtils) RyaURI(org.apache.rya.api.domain.RyaURI) HashJoin(org.apache.rya.api.persist.query.join.HashJoin) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) RyaType(org.apache.rya.api.domain.RyaType) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with HashJoin

use of org.apache.rya.api.persist.query.join.HashJoin in project incubator-rya by apache.

the class HashJoinTest method testSimpleJoinMultiWay.

@Test
public void testSimpleJoinMultiWay() 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
    HashJoin hjoin = new HashJoin(dao.getQueryEngine());
    CloseableIteration<RyaURI, RyaDAOException> join = hjoin.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();
}
Also used : RdfCloudTripleStoreUtils(org.apache.rya.api.RdfCloudTripleStoreUtils) RyaURI(org.apache.rya.api.domain.RyaURI) HashJoin(org.apache.rya.api.persist.query.join.HashJoin) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) RyaType(org.apache.rya.api.domain.RyaType) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with HashJoin

use of org.apache.rya.api.persist.query.join.HashJoin in project incubator-rya by apache.

the class HashJoinTest 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
    HashJoin hjoin = new HashJoin(dao.getQueryEngine());
    CloseableIteration<RyaURI, RyaDAOException> join = hjoin.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(subj4));
    join.close();
}
Also used : RdfCloudTripleStoreUtils(org.apache.rya.api.RdfCloudTripleStoreUtils) RyaURI(org.apache.rya.api.domain.RyaURI) HashJoin(org.apache.rya.api.persist.query.join.HashJoin) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) RyaType(org.apache.rya.api.domain.RyaType) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

RyaStatement (org.apache.rya.api.domain.RyaStatement)7 RyaType (org.apache.rya.api.domain.RyaType)7 RyaURI (org.apache.rya.api.domain.RyaURI)7 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)7 HashJoin (org.apache.rya.api.persist.query.join.HashJoin)7 Test (org.junit.Test)7 RdfCloudTripleStoreUtils (org.apache.rya.api.RdfCloudTripleStoreUtils)5 HashSet (java.util.HashSet)3