@Test public void testSegmentWithLargeUnion() throws Exception { final String query1 = "" + "SELECT ?e ?c ?l" + "{" + " {?e <uri:p1> <uri:o1>. } UNION { " + " ?e <uri:p0> ?l ." + " ?l <uri:p5> <uri:o5> ." + " OPTIONAL{?l <uri:p4> <uri:o4>} ." + " ?c<uri:p1> ?l ." + " OPTIONAL{ ?e <uri:p1> ?c } ." + " ?e <uri:p2> <uri:o2>. " + " ?c <uri:p3> <uri:o3> " + " } . " + " ?e <uri:p2> ?c . " + " ?e <uri:p3> <uri:o2> . " + "}"; final String query2 = "" + "SELECT ?a ?b ?c " + "{" + " ?a <uri:p2> <uri:o2>. " + " ?b <uri:p3> <uri:o3>. " + " OPTIONAL{ ?a <uri:p1> ?b } ." + " ?a <uri:p0> ?c ." + " ?b<uri:p1> ?c " + "}"; final String query3 = "" + "SELECT ?h ?i" + "{" + " ?h <uri:p2> ?i . " + " ?h <uri:p3> <uri:o2> . " + "}"; final SPARQLParser parser = new SPARQLParser(); final ParsedQuery pq1 = parser.parseQuery(query1, null); final ParsedQuery pq2 = parser.parseQuery(query2, null); final ParsedQuery pq3 = parser.parseQuery(query3, null); final TupleExpr te1 = pq1.getTupleExpr(); final TupleExpr te2 = pq2.getTupleExpr(); final TupleExpr te3 = pq3.getTupleExpr(); final TupleExpr unOpt = te1.clone(); final List<QueryModelNode> remainingNodes = getNodes(te1); final Set<QueryModelNode> unMatchedNodes = new HashSet<>(); unMatchedNodes.add(remainingNodes.get(0)); unMatchedNodes.add(remainingNodes.get(2)); unMatchedNodes.add(remainingNodes.get(3)); final SimpleExternalTupleSet pcj1 = new SimpleExternalTupleSet((Projection) te2); final SimpleExternalTupleSet pcj2 = new SimpleExternalTupleSet((Projection) te3); final List<ExternalTupleSet> externalList = new ArrayList<>(); externalList.add(pcj1); externalList.add(pcj2); provider.setIndices(externalList); final PCJOptimizer optimizer = new PCJOptimizer(externalList, false, provider); optimizer.optimize(te1, null, null); Assert.assertEquals(true, validatePcj(te1, unOpt, externalList, unMatchedNodes)); }
@Override public void optimize(TupleExpr tupleExpr, final Dataset dataset, final BindingSet bindings) { checkNotNull(tupleExpr); tupleExpr = TopOfQueryFilterRelocator.moveFiltersToTop(tupleExpr); try { if (provider.size() > 0) { super.optimize(tupleExpr, null, null); } else { return; } } catch (final Exception e) { throw new RuntimeException("Could not populate Index Cache.", e); } }
PCJOptimizer extends AbstractExternalSetOptimizer<ExternalTupleSet> implements Configurable { @Override public void optimize(TupleExpr tupleExpr, final Dataset dataset, final BindingSet bindings) { checkNotNull(tupleExpr); tupleExpr = TopOfQueryFilterRelocator.moveFiltersToTop(tupleExpr); try { if (provider.size() > 0) { super.optimize(tupleExpr, null, null); } else { return; } } catch (final Exception e) { throw new RuntimeException("Could not populate Index Cache.", e); } } }
PCJOptimizer extends AbstractExternalSetOptimizer<ExternalTupleSet> implements Configurable { @Override public void optimize(TupleExpr tupleExpr, final Dataset dataset, final BindingSet bindings) { checkNotNull(tupleExpr); tupleExpr = TopOfQueryFilterRelocator.moveFiltersToTop(tupleExpr); try { if (provider.size() > 0) { super.optimize(tupleExpr, null, null); } else { return; } } catch (final Exception e) { throw new RuntimeException("Could not populate Index Cache.", e); } } PCJOptimizer();  PCJOptimizer(final Configuration conf);  PCJOptimizer(final List<ExternalTupleSet> indices, final boolean useOptimalPcj,
            final AbstractPcjIndexSetProvider provider); }
PCJOptimizer extends AbstractExternalSetOptimizer<ExternalTupleSet> implements Configurable { @Override public void optimize(TupleExpr tupleExpr, final Dataset dataset, final BindingSet bindings) { checkNotNull(tupleExpr); tupleExpr = TopOfQueryFilterRelocator.moveFiltersToTop(tupleExpr); try { if (provider.size() > 0) { super.optimize(tupleExpr, null, null); } else { return; } } catch (final Exception e) { throw new RuntimeException("Could not populate Index Cache.", e); } } PCJOptimizer();  PCJOptimizer(final Configuration conf);  PCJOptimizer(final List<ExternalTupleSet> indices, final boolean useOptimalPcj,
            final AbstractPcjIndexSetProvider provider); @Override final void setConf(final Configuration conf); @Override Configuration getConf(); @Override void optimize(TupleExpr tupleExpr, final Dataset dataset, final BindingSet bindings); }
PCJOptimizer extends AbstractExternalSetOptimizer<ExternalTupleSet> implements Configurable { @Override public void optimize(TupleExpr tupleExpr, final Dataset dataset, final BindingSet bindings) { checkNotNull(tupleExpr); tupleExpr = TopOfQueryFilterRelocator.moveFiltersToTop(tupleExpr); try { if (provider.size() > 0) { super.optimize(tupleExpr, null, null); } else { return; } } catch (final Exception e) { throw new RuntimeException("Could not populate Index Cache.", e); } } PCJOptimizer();  PCJOptimizer(final Configuration conf);  PCJOptimizer(final List<ExternalTupleSet> indices, final boolean useOptimalPcj,
            final AbstractPcjIndexSetProvider provider); @Override final void setConf(final Configuration conf); @Override Configuration getConf(); @Override void optimize(TupleExpr tupleExpr, final Dataset dataset, final BindingSet bindings);  }