@Override
public synchronized OptionalResult processJoin(final QueryResult bindings,
final int operandID) {
// different from process:
final OptionalResult or = new OptionalResult();
// different from process:
final QueryResult joinPartnerFromLeftOperand = this.createQueryResult();
final QueryResult result = this.createQueryResult();
int otherOperand = 1-operandID;
final Iterator<Bindings> itbindings = bindings.oneTimeIterator();
while (itbindings.hasNext()) {
final Bindings binding = itbindings.next();
String keyJoin = "";
final Iterator<Variable> it = this.intersectionVariables.iterator();
while (it.hasNext()) {
final Literal literal = binding.get(it.next());
if (literal == null) {
boolean added = this.cartesianProduct[operandID].add(binding);
if(added || !isDuplicateEliminationEnabled()){
// build the cartesian product
for (final Bindings b2 : this.cartesianProduct[otherOperand]) {
if(joinBindings(result, binding.clone(), b2)){
if (operandID == 1) {
joinPartnerFromLeftOperand.add(b2);
} else {
joinPartnerFromLeftOperand.add(binding);
}
}
}
for (final QueryResult qr : this.lba[otherOperand].values()) {
for (final Bindings b2 : qr) {
if(joinBindings(result, binding.clone(), b2)){
if (operandID == 1) {
joinPartnerFromLeftOperand.add(b2);
} else {
joinPartnerFromLeftOperand.add(binding);
}
}
}
}
}
keyJoin = null;
break;
}
keyJoin += "|" + literal.getKey();
}
if (keyJoin == null)
continue;
QueryResult lb = this.lba[operandID].get(keyJoin);
if (lb == null){
lb = this.createQueryResult();
}
boolean added = lb.add(binding);
if(added || !isDuplicateEliminationEnabled()){
this.lba[operandID].put(keyJoin, lb);
final QueryResult toJoin = this.lba[otherOperand].get(keyJoin);
if (toJoin != null) {
final Iterator<Bindings> itb = toJoin.iterator();
while (itb.hasNext()) {
final Bindings b2 = itb.next();
// different from process:
if (joinBindings(result, binding.clone(), b2)) {
if (operandID == 1) {
joinPartnerFromLeftOperand.add(b2);
} else {
joinPartnerFromLeftOperand.add(binding);
}
}
}
}
// build cartesian product
for (final Bindings b2 : this.cartesianProduct[otherOperand]) {
if(joinBindings(result, binding.clone(), b2)){
if (operandID == 1) {
joinPartnerFromLeftOperand.add(b2);
} else {
joinPartnerFromLeftOperand.add(binding);
}
}
}
}
}
// different from process:
or.setJoinPartnerFromLeftOperand(joinPartnerFromLeftOperand);
// different from process:
or.setJoinResult(result);
// different from process:
return or;
}