}
// TODO consider graphConstraint!
this.indexScanCreator.createEmptyIndexScanSubmittingQueryResultWithOneEmptyBindingsAndConnectWithRoot(new OperatorIDTuple(projection,0), graphConstraint);
return projection;
} else if (!getItem(subjectNode).isVariable()){
final Bind firstBind = new Bind(object);
firstBind.addProjectionElement(object, subjectNode);
// TODO consider graphConstraint!
this.indexScanCreator.createEmptyIndexScanSubmittingQueryResultWithOneEmptyBindingsAndConnectWithRoot(new OperatorIDTuple(firstBind,0), graphConstraint);
return firstBind;
} else if(!getItem(objectNode).isVariable()){
final LinkedList<TriplePattern> temp = new LinkedList<TriplePattern>();
final Item[] items = {subject, getItem(node.jjtGetChild(0)), object};
temp.add(new TriplePattern(items));
final Bind firstBind = new Bind(subject);
firstBind.addProjectionElement(subject, objectNode);
// TODO consider graphConstraint!
this.indexScanCreator.createEmptyIndexScanSubmittingQueryResultWithOneEmptyBindingsAndConnectWithRoot(new OperatorIDTuple(firstBind,0), graphConstraint);
return firstBind;
} else {
final Union union = new Union();
final Variable intermediatePredicate = this.getVariable(subject.toString(),object.toString(),"intermediatePredicate");
final Variable intermediateObject = this.getVariable(subject.toString(),object.toString(),"intermediateObject");
final Item[] items = {subject, intermediatePredicate, intermediateObject};
LinkedList<TriplePattern> temp = new LinkedList<TriplePattern>();
TriplePattern tp = new TriplePattern(items);
temp.add(tp);
this.indexScanCreator.createIndexScanAndConnectWithRoot(new OperatorIDTuple(union,0), temp, graphConstraint);
items[0] = intermediateObject;
items[1] = intermediatePredicate;
items[2] = subject;
temp = new LinkedList<TriplePattern>();
tp = new TriplePattern(items.clone());
temp.add(tp);
this.indexScanCreator.createIndexScanAndConnectWithRoot(new OperatorIDTuple(union,1), temp, graphConstraint);
final Projection projection = new Projection();
projection.addProjectionElement(subject);
projection.addProjectionElement(object);
if(graphConstraint!=null && graphConstraint.isVariable() && !graphConstraint.equals(getItem(subjectNode)) && !graphConstraint.equals(getItem(objectNode))) {
projection.addProjectionElement((Variable)graphConstraint);
}
final ASTVar n = new ASTVar(100);
n.setName(subject.toString().substring(1));
final Bind bind = new Bind(subject);
bind.addProjectionElement(object,n);
union.addSucceedingOperator(new OperatorIDTuple(bind,0));
bind.addSucceedingOperator(new OperatorIDTuple(projection,0));
final InMemoryDistinct memoryDistinct = new InMemoryDistinct();
projection.addSucceedingOperator(new OperatorIDTuple(memoryDistinct,0));
return memoryDistinct;
}
}