use of org.apache.rya.indexing.external.tupleSet.SimpleExternalTupleSet in project incubator-rya by apache.
the class PCJOptionalTestIT method testSimpleOptionalTest2.
@Test
public void testSimpleOptionalTest2() throws Exception {
final String query = //
"" + //
"SELECT ?u ?s ?t " + //
"{" + //
" ?s a ?t ." + //
" OPTIONAL{?t <http://www.w3.org/2000/01/rdf-schema#label> ?u } ." + //
" ?u <uri:talksTo> ?s . " + //
" ?s a ?u ." + //
"}";
final String pcj = //
"" + //
"SELECT ?d ?b ?c " + //
"{" + //
" ?b a ?c ." + //
" OPTIONAL{?c <http://www.w3.org/2000/01/rdf-schema#label> ?d } ." + //
" ?d <uri:talksTo> ?b . " + //
"}";
final String relabel_pcj = //
"" + //
"SELECT ?u ?s ?t " + //
"{" + //
" ?s a ?t ." + //
" OPTIONAL{?t <http://www.w3.org/2000/01/rdf-schema#label> ?u } ." + //
" ?u <uri:talksTo> ?s . " + //
"}";
final SPARQLParser parser = new SPARQLParser();
final ParsedQuery pq1 = parser.parseQuery(query, null);
final ParsedQuery pq2 = parser.parseQuery(pcj, null);
final ParsedQuery pq3 = parser.parseQuery(relabel_pcj, null);
final SimpleExternalTupleSet extTup1 = new SimpleExternalTupleSet((Projection) pq2.getTupleExpr());
final SimpleExternalTupleSet extTup2 = new SimpleExternalTupleSet((Projection) pq3.getTupleExpr());
final List<ExternalTupleSet> list = new ArrayList<ExternalTupleSet>();
list.add(extTup1);
final List<QueryModelNode> optTupNodes = Lists.newArrayList();
optTupNodes.add(extTup2);
final PCJOptimizer opt = new PCJOptimizer(list, true, new AccumuloIndexSetProvider(new Configuration(), list));
final TupleExpr te = pq1.getTupleExpr();
opt.optimize(te, null, null);
final NodeCollector nc = new NodeCollector();
te.visit(nc);
final List<QueryModelNode> qNodes = nc.getNodes();
Assert.assertEquals(qNodes.size(), optTupNodes.size() + 1);
for (final QueryModelNode node : optTupNodes) {
Assert.assertTrue(qNodes.contains(node));
}
}
use of org.apache.rya.indexing.external.tupleSet.SimpleExternalTupleSet in project incubator-rya by apache.
the class PrecompJoinOptimizerTest2 method testContextFilter2.
@Test
public void testContextFilter2() throws Exception {
final SPARQLParser parser1 = new SPARQLParser();
final SPARQLParser parser2 = new SPARQLParser();
final String query1 = //
"" + //
"SELECT ?k ?l ?m ?n " + //
"{" + //
" GRAPH ?z { " + //
" ?l <uri:talksTo> ?n . " + //
" ?l a ?n." + //
" ?k a ?m." + //
" FILTER ((?k < ?l) && (?m < ?n)). " + //
" }" + //
"}";
final String query2 = //
"" + //
"SELECT ?s ?t " + //
"{" + //
" GRAPH ?r { " + //
" ?s <uri:talksTo> ?t . " + //
" ?s a ?t." + //
" }" + //
"}";
final ParsedQuery pq1 = parser1.parseQuery(query1, null);
final ParsedQuery pq2 = parser2.parseQuery(query2, null);
final SimpleExternalTupleSet extTup1 = new SimpleExternalTupleSet((Projection) pq2.getTupleExpr());
final List<ExternalTupleSet> list = new ArrayList<ExternalTupleSet>();
list.add(extTup1);
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.assertTrue(qSet.containsAll(set) && eTupSet.size() == 1);
}
use of org.apache.rya.indexing.external.tupleSet.SimpleExternalTupleSet in project incubator-rya by apache.
the class PrecompJoinOptimizerTest2 method testVarRelableIndexSameSize.
@Test
public void testVarRelableIndexSameSize() throws Exception {
final SPARQLParser parser1 = new SPARQLParser();
final SPARQLParser parser2 = new SPARQLParser();
final ParsedQuery pq1 = parser1.parseQuery(q1, null);
final ParsedQuery pq2 = parser2.parseQuery(q2, null);
final SimpleExternalTupleSet extTup = new SimpleExternalTupleSet(new Projection(pq2.getTupleExpr()));
final List<ExternalTupleSet> list = new ArrayList<ExternalTupleSet>();
list.add(extTup);
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.assertTrue(set.equals(qSet));
}
use of org.apache.rya.indexing.external.tupleSet.SimpleExternalTupleSet in project incubator-rya by apache.
the class PrecompJoinOptimizerTest2 method testGeoIndexFunction.
@Test
public void testGeoIndexFunction() throws Exception {
final SPARQLParser parser1 = new SPARQLParser();
final SPARQLParser parser2 = new SPARQLParser();
final ParsedQuery pq1 = parser1.parseQuery(q21, null);
final ParsedQuery pq2 = parser2.parseQuery(q23, null);
System.out.println("Query is " + pq1.getTupleExpr());
System.out.println("Index is " + pq2.getTupleExpr());
final SimpleExternalTupleSet extTup = new SimpleExternalTupleSet(new Projection(pq2.getTupleExpr()));
final List<ExternalTupleSet> list = new ArrayList<ExternalTupleSet>();
list.add(extTup);
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.assertTrue(qSet.containsAll(set) && set.size() != 0);
}
use of org.apache.rya.indexing.external.tupleSet.SimpleExternalTupleSet in project incubator-rya by apache.
the class PrecompJoinOptimizerTest2 method testThreeIndexGeoFreeCompareFilterMix.
@Test
public void testThreeIndexGeoFreeCompareFilterMix() throws Exception {
final SPARQLParser parser1 = new SPARQLParser();
final SPARQLParser parser2 = new SPARQLParser();
final SPARQLParser parser3 = new SPARQLParser();
final ParsedQuery pq1 = parser1.parseQuery(q25, null);
final ParsedQuery pq2 = parser2.parseQuery(q24, null);
final ParsedQuery pq3 = parser3.parseQuery(q26, 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.assertTrue(set.equals(qSet) && eTupSet.size() == 2);
}
Aggregations