本文整理汇总了Java中org.openrdf.query.algebra.TupleExpr.clone方法的典型用法代码示例。如果您正苦于以下问题:Java TupleExpr.clone方法的具体用法?Java TupleExpr.clone怎么用?Java TupleExpr.clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openrdf.query.algebra.TupleExpr
的用法示例。
在下文中一共展示了TupleExpr.clone方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPlans
import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
private static List<TupleExpr> getPlans(List<Map<Join, List<TupleExpr>>> reOrderings, TupleExpr te) {
List<TupleExpr> queryPlans = Lists.newArrayList();
PermInserter pm = new PermInserter();
for (Map<Join, List<TupleExpr>> order : reOrderings) {
TupleExpr clone = te.clone();
pm.setReOrderMap(order);
clone.visit(pm);
queryPlans.add(clone);
}
return queryPlans;
}
示例2: testJoinMatcherRejectsLeftJoinPcj
import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
@Test
public void testJoinMatcherRejectsLeftJoinPcj() throws Exception {
final String query1 = ""//
+ "SELECT ?e ?c ?l" //
+ "{" //
+ " ?e a ?c . "//
+ " ?e <uri:talksTo> ?l . "//
+ " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "//
+ "}";//
final String query2 = ""//
+ "SELECT ?a ?b ?m" //
+ "{" //
+ " ?a a ?b . "//
+ " ?a <uri:talksTo> ?m . "//
+ " OPTIONAL {?a <http://www.w3.org/2000/01/rdf-schema#label> ?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 expected = te1.clone();
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(expected, te1);
}
示例3: evaluateInternal
import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
/**
* Evaluates the supplied QueryModel on the federation members.
*
* @param query
* The query to evaluate.
* @param bindings
* A set of input parameters for the query evaluation. The keys
* reference variable names that should be bound to the value
* they map to.
* @param includeInferred
* Indicates whether inferred triples are to be considered in the
* query result. If false, no inferred statements are returned;
* if true, inferred statements are returned if available
* @return The result Cursor.
* @throws StoreException
* If the Sail encountered an error or invalid internal state.
*/
@Override
public CloseableIteration<? extends BindingSet, QueryEvaluationException> evaluateInternal(TupleExpr query, Dataset dataset,
BindingSet bindings, boolean includeInferred) throws SailException { // Sesame 2:
QueryOptimizerList optimizerList = new QueryOptimizerList();
LOGGER.trace("Incoming query model:\n{}", OperatorTreePrinter.print(query));
// Clone the tuple expression to allow for more aggressive optimizations
query = query.clone();
optimizerList.add(new BindingAssigner());
optimizerList.add(new CompareOptimizer());
optimizerList.add(new ConjunctiveConstraintSplitter());
optimizerList.add(new DisjunctiveConstraintOptimizer());
optimizerList.add(new SameTermFilterOptimizer());
// optimizerList.add(new FilterOptimizer());
// optimizerList.add(new QueryModelPruner());
optimizerList.add(this.optimizer);
optimizerList.optimize(query, dataset, bindings);
if (LOGGER.isTraceEnabled())
LOGGER.trace("Optimized query model:\n{}", OperatorTreePrinter.print(query));
try {
return strategy.evaluate(query, EmptyBindingSet.getInstance());
} catch (QueryEvaluationException e) {
throw new SailException("query evaluation failed", e);
}
}
示例4: process
import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
/**
* Iterates through list of normalized indexes and replaces all subtrees of query which match index with index.
*
* @param query
* @return TupleExpr
*/
public static TupleExpr process(TupleExpr query, List<ExternalTupleSet> indexSet) {
boolean indexPlaced = false;
TupleExpr rtn = query.clone();
QueryNodeCount qnc = new QueryNodeCount();
rtn.visit(qnc);
if(qnc.getNodeCount()/2 < indexSet.size()) {
return null;
}
//move BindingSetAssignment Nodes out of the way
organizeBSAs(rtn);
// test to see if query contains no other nodes
// than filter, join, projection, and statement pattern and
// test whether query contains duplicate StatementPatterns and filters
if (isTupleValid(rtn)) {
for (ExternalTupleSet index : indexSet) {
// test to see if index contains at least one StatementPattern,
// that StatementPatterns are unique,
// and that all variables found in filters occur in some
// StatementPattern
if (isTupleValid(index.getTupleExpr())) {
ExternalTupleSet eTup = (ExternalTupleSet) index.clone();
SPBubbleDownVisitor indexVistor = new SPBubbleDownVisitor(eTup);
rtn.visit(indexVistor);
FilterBubbleManager fbmv = new FilterBubbleManager(eTup);
rtn.visit(fbmv);
SubsetEqualsVisitor subIndexVis = new SubsetEqualsVisitor(eTup, rtn);
rtn.visit(subIndexVis);
indexPlaced = subIndexVis.indexPlaced();
if(!indexPlaced) {
break;
}
}
}
if(indexPlaced) {
return rtn;
} else {
return null;
}
} else {
throw new IllegalArgumentException("Invalid Query.");
}
}
示例5: testBasicSegment
import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
@Test
public void testBasicSegment() throws Exception {
final String query1 = ""//
+ "SELECT ?e ?c ?l" //
+ "{" //
+ " ?e a ?c . "//
+ " OPTIONAL {?e <uri:talksTo> ?l} . "//
+ " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "//
+ "}";//
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));
}
示例6: testSegmentWithUnion
import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
@Test
public void testSegmentWithUnion() throws Exception {
final String query1 = ""//
+ "SELECT ?e ?c ?l" //
+ "{" //
+ " {?e <uri:p1> <uri:o1>. } UNION { ?e a ?c. OPTIONAL {?e <uri:talksTo> ?l}. ?e <uri:p5> <uri:o4>. ?e <uri:p4> <uri:o3> } . "//
+ " ?e <uri:p2> ?c . "//
+ " ?e <uri:p3> <uri:o2> . "//
+ "}";//
final String query2 = ""//
+ "SELECT ?a ?b ?m" //
+ "{" //
+ " ?a <uri:p5> <uri:o4> ." //
+ " ?a <uri:p4> <uri:o3> ." //
+ " OPTIONAL {?a <uri:talksTo> ?m} . "//
+ " ?a a ?b . "//
+ "}";//
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));
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));
}
示例7: testExactMatchLargeReOrdered
import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
@Test
public void testExactMatchLargeReOrdered() throws Exception {
final String query1 = ""//
+ "SELECT ?a ?b ?c ?d ?e ?f ?g ?h" //
+ "{" //
+ " ?a <uri:p0> ?b ." //
+ " OPTIONAL{?b <uri:p2> ?c. ?c <uri:p1> ?d} . " //
+ " OPTIONAL{?b <uri:p3> ?e. ?e <uri:p1> ?f} . "//
+ " OPTIONAL{?b <uri:p4> ?g. ?g <uri:p1> ?h} . "//
+ " OPTIONAL{?b <uri:p4> ?i. ?i <uri:p1> ?j} . "//
+ " OPTIONAL{?b <uri:p4> ?k. ?k <uri:p1> ?l} . "//
+ " OPTIONAL{?b <uri:p4> ?m. ?m <uri:p1> ?n} . "//
+ " OPTIONAL{?b <uri:p4> ?o. ?o <uri:p1> ?p} . "//
+ "}";//
final String query2 = ""//
+ "SELECT ?a ?b ?c ?d ?e ?f ?g ?h" //
+ "{" //
+ " ?a <uri:p0> ?b ." //
+ " OPTIONAL{?b <uri:p4> ?o. ?o <uri:p1> ?p} . "//
+ " OPTIONAL{?b <uri:p4> ?g. ?g <uri:p1> ?h} . "//
+ " OPTIONAL{?b <uri:p2> ?c. ?c <uri:p1> ?d} . " //
+ " OPTIONAL{?b <uri:p4> ?i. ?i <uri:p1> ?j} . "//
+ " OPTIONAL{?b <uri:p4> ?m. ?m <uri:p1> ?n} . "//
+ " OPTIONAL{?b <uri:p4> ?k. ?k <uri:p1> ?l} . "//
+ " OPTIONAL{?b <uri:p3> ?e. ?e <uri:p1> ?f} . "//
+ "}";//
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 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, new HashSet<QueryModelNode>()));
}
示例8: testSubsetMatchLargeReOrdered
import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
@Test
public void testSubsetMatchLargeReOrdered() throws Exception {
final String query1 = ""//
+ "SELECT ?a ?b ?c ?d ?e ?f ?g ?h" //
+ "{" //
+ " ?a <uri:p0> ?b ." //
+ " OPTIONAL{?b <uri:p2> ?c. ?c <uri:p1> ?d} . " //
+ " OPTIONAL{?b <uri:p3> ?e. ?e <uri:p1> ?f} . "//
+ " OPTIONAL{?b <uri:p4> ?g. ?g <uri:p1> ?h} . "//
+ " OPTIONAL{?b <uri:p5> ?i. ?i <uri:p6> ?j} . "//
+ " OPTIONAL{?b <uri:p5> ?k. ?k <uri:p6> ?l} . "//
+ " OPTIONAL{?b <uri:p5> ?m. ?m <uri:p6> ?n} . "//
+ " OPTIONAL{?b <uri:p4> ?o. ?o <uri:p1> ?p} . "//
+ "}";//
final String query2 = ""//
+ "SELECT ?a ?b ?c ?d ?e ?f ?g ?h" //
+ "{" //
+ " ?a <uri:p0> ?b ." //
+ " OPTIONAL{?b <uri:p4> ?o. ?o <uri:p1> ?p} . "//
+ " OPTIONAL{?b <uri:p4> ?g. ?g <uri:p1> ?h} . "//
+ " OPTIONAL{?b <uri:p2> ?c. ?c <uri:p1> ?d} . " //
+ " OPTIONAL{?b <uri:p3> ?e. ?e <uri:p1> ?f} . "//
+ "}";//
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(8));
unMatchedNodes.add(remainingNodes.get(9));
unMatchedNodes.add(remainingNodes.get(10));
unMatchedNodes.add(remainingNodes.get(11));
unMatchedNodes.add(remainingNodes.get(12));
unMatchedNodes.add(remainingNodes.get(7));
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));
}
示例9: testSwitchTwoBoundVars
import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
@Test
public void testSwitchTwoBoundVars() throws Exception {
final String query1 = ""//
+ "SELECT ?a ?b ?c " //
+ "{" //
+ " ?a <uri:p0> ?c ." //
+ " ?c <uri:p5> <uri:o5> ." //
+ " OPTIONAL{?c <uri:p4> <uri:o4>} ."
+ " ?b<uri:p1> ?c ." //
+ " OPTIONAL{ ?a <uri:p1> ?b } ." //
+ " ?a <uri:p2> <uri:o2>. " //
+ " ?b <uri:p3> <uri:o3> " //
+ "}";//
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 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(1));
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));
}
示例10: testSegmentWithLargeUnion
import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
@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));
}
示例11: testSegmentWithUnionAndFilters
import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
@Test
public void testSegmentWithUnionAndFilters() throws Exception {
final String query1 = ""//
+ "SELECT ?e ?c ?l" //
+ "{" //
+ " Filter(?e = <uri:s1>) " //
+ " Filter(?c = <uri:s2>) " //
+ " {?e <uri:p1> <uri:o1>. } UNION { ?e a ?c. OPTIONAL {?e <uri:talksTo> ?l}. ?e <uri:p5> <uri:o4>. ?e <uri:p4> <uri:o3> } . "//
+ " ?e <uri:p2> ?c . "//
+ " ?e <uri:p3> <uri:o2> . "//
+ "}";//
final String query2 = ""//
+ "SELECT ?a ?b ?m" //
+ "{" //
+ " Filter(?b = <uri:s2>) " //
+ " ?a <uri:p5> <uri:o4> ." //
+ " ?a <uri:p4> <uri:o3> ." //
+ " OPTIONAL {?a <uri:talksTo> ?m} . "//
+ " ?a a ?b . "//
+ "}";//
final String query3 = ""//
+ "SELECT ?h ?i" //
+ "{" //
+ " Filter(?h = <uri:s1>) " //
+ " ?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));
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));
}
示例12: testSegmentWithLeftJoinsAndFilters
import org.openrdf.query.algebra.TupleExpr; //导入方法依赖的package包/类
@Test
public void testSegmentWithLeftJoinsAndFilters() throws Exception {
final String query1 = ""//
+ "SELECT ?e ?c ?l" //
+ "{" //
+ " Filter(?e = <uri:s1>) " //
+ " Filter(?c = <uri:s2>) " //
+ " ?e <uri:p1> <uri:o1>. " + " OPTIONAL {?e <uri:p2> ?l}. " + " ?c <uri:p3> <uri:o3> . "//
+ " ?c <uri:p4> ?e . "//
+ " OPTIONAL {?e <uri:p2> ?c } . "//
+ "}";//
final String query2 = ""//
+ "SELECT ?e ?c ?l" //
+ "{" //
+ " Filter(?c = <uri:s2>) " //
+ " ?e <uri:p1> <uri:o1>. " + " OPTIONAL {?e <uri:p2> ?l}. " + " ?c <uri:p3> <uri:o3> . "//
+ "}";//
final String query3 = ""//
+ "SELECT ?e ?c" //
+ "{" //
+ " Filter(?e = <uri:s1>) " //
+ " ?c <uri:p4> ?e . "//
+ " OPTIONAL {?e <uri:p2> ?c } . "//
+ "}";//
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 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, new HashSet<QueryModelNode>()));
}