Search in sources :

Example 1 with BindingSetAssignmentCollector

use of org.apache.rya.indexing.external.PcjIntegrationTestingUtil.BindingSetAssignmentCollector in project incubator-rya by apache.

the class PrecompJoinOptimizerTest2 method testBindingSetAssignment2.

@Test
public void testBindingSetAssignment2() throws Exception {
    final SPARQLParser parser = new SPARQLParser();
    final ParsedQuery pq1 = parser.parseQuery(q41, null);
    final ParsedQuery pq2 = parser.parseQuery(q42, null);
    final ParsedQuery pq3 = parser.parseQuery(q43, null);
    final SimpleExternalTupleSet extTup1 = new SimpleExternalTupleSet(new Projection(pq2.getTupleExpr()));
    final SimpleExternalTupleSet extTup2 = new SimpleExternalTupleSet(new Projection(pq3.getTupleExpr()));
    final List<ExternalTupleSet> list = new ArrayList<ExternalTupleSet>();
    list.add(extTup1);
    list.add(extTup2);
    final TupleExpr tup = pq1.getTupleExpr().clone();
    provider.setIndices(list);
    final PCJOptimizer pcj = new PCJOptimizer(list, false, provider);
    pcj.optimize(tup, null, null);
    final Set<StatementPattern> qSet = Sets.newHashSet(StatementPatternCollector.process(pq1.getTupleExpr()));
    final Set<QueryModelNode> eTupSet = PcjIntegrationTestingUtil.getTupleSets(tup);
    final Set<StatementPattern> set = Sets.newHashSet();
    for (final QueryModelNode s : eTupSet) {
        set.addAll(StatementPatternCollector.process(((ExternalTupleSet) s).getTupleExpr()));
    }
    Assert.assertEquals(2, eTupSet.size());
    Assert.assertEquals(qSet, set);
    final BindingSetAssignmentCollector bsac1 = new BindingSetAssignmentCollector();
    final BindingSetAssignmentCollector bsac2 = new BindingSetAssignmentCollector();
    pq1.getTupleExpr().visit(bsac1);
    tup.visit(bsac2);
    Assert.assertEquals(bsac1.getBindingSetAssignments(), bsac2.getBindingSetAssignments());
}
Also used : SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser) ParsedQuery(org.openrdf.query.parser.ParsedQuery) ArrayList(java.util.ArrayList) Projection(org.openrdf.query.algebra.Projection) QueryModelNode(org.openrdf.query.algebra.QueryModelNode) TupleExpr(org.openrdf.query.algebra.TupleExpr) SimpleExternalTupleSet(org.apache.rya.indexing.external.tupleSet.SimpleExternalTupleSet) ExternalTupleSet(org.apache.rya.indexing.external.tupleSet.ExternalTupleSet) BindingSetAssignmentCollector(org.apache.rya.indexing.external.PcjIntegrationTestingUtil.BindingSetAssignmentCollector) StatementPattern(org.openrdf.query.algebra.StatementPattern) SimpleExternalTupleSet(org.apache.rya.indexing.external.tupleSet.SimpleExternalTupleSet) PCJOptimizer(org.apache.rya.indexing.pcj.matching.PCJOptimizer) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 BindingSetAssignmentCollector (org.apache.rya.indexing.external.PcjIntegrationTestingUtil.BindingSetAssignmentCollector)1 ExternalTupleSet (org.apache.rya.indexing.external.tupleSet.ExternalTupleSet)1 SimpleExternalTupleSet (org.apache.rya.indexing.external.tupleSet.SimpleExternalTupleSet)1 PCJOptimizer (org.apache.rya.indexing.pcj.matching.PCJOptimizer)1 Test (org.junit.Test)1 Projection (org.openrdf.query.algebra.Projection)1 QueryModelNode (org.openrdf.query.algebra.QueryModelNode)1 StatementPattern (org.openrdf.query.algebra.StatementPattern)1 TupleExpr (org.openrdf.query.algebra.TupleExpr)1 ParsedQuery (org.openrdf.query.parser.ParsedQuery)1 SPARQLParser (org.openrdf.query.parser.sparql.SPARQLParser)1