@Test public void testBasicSegment() throws Exception { final String query1 = "" + "SELECT ?e ?c ?l" + "{" + " ?e a ?c . " + " OPTIONAL {?e <uri:talksTo> ?l} . " + " ?e <http: + "}"; final String query2 = "" + "SELECT ?a ?b ?m" + "{" + " ?a a ?b . " + " OPTIONAL {?a <uri:talksTo> ?m} . " + "}"; final SPARQLParser parser = new SPARQLParser(); final ParsedQuery pq1 = parser.parseQuery(query1, null); final ParsedQuery pq2 = parser.parseQuery(query2, null); final TupleExpr te1 = pq1.getTupleExpr(); final TupleExpr te2 = pq2.getTupleExpr(); final TupleExpr unOpt = te1.clone(); final List<QueryModelNode> remainingNodes = getNodes(te1); final Set<QueryModelNode> unMatchedNodes = new HashSet<>(); unMatchedNodes.add(remainingNodes.get(2)); final SimpleExternalTupleSet pcj = new SimpleExternalTupleSet((Projection) te2); final List<ExternalTupleSet> externalList = new ArrayList<>(); externalList.add(pcj); 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);  }