/** * @inheritDoc */ @Override public void meet(LeftJoin theJoin) throws Exception { binaryOpMeet(theJoin, theJoin.getLeftArg(), theJoin.getRightArg()); }
/** * @inheritDoc */ @Override public void meet(LeftJoin theJoin) throws Exception { theJoin.getLeftArg().visit(this); mJoinBuffer.append(" ["); theJoin.getRightArg().visit(this); if (theJoin.getCondition() != null) { mJoinBuffer.append(renderValueExpr(theJoin.getCondition())); } mJoinBuffer.setCharAt(mJoinBuffer.lastIndexOf(","), ' '); mJoinBuffer.append("], "); }
@Override public LeftJoin clone() { LeftJoin clone = (LeftJoin)super.clone(); if (hasCondition()) { clone.setCondition(getCondition().clone()); } return clone; } }
@Override public boolean equals(Object other) { if (other instanceof LeftJoin && super.equals(other)) { ValueExpr oCond = ((LeftJoin)other).getCondition(); return nullEquals(condition, oCond); } return false; }
@Override public int hashCode() { int result = super.hashCode() ^ "LeftJoin".hashCode(); if (hasCondition()) { result ^= getCondition().hashCode(); } return result; }
public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(LeftJoin leftJoin, final BindingSet bindings) throws QueryEvaluationException { if (TupleExprs.containsSubquery(leftJoin.getRightArg())) { return new HashJoinIteration(this, leftJoin, bindings); } // Check whether optional join is "well designed" as defined in section // 4.2 of "Semantics and Complexity of SPARQL", 2006, Jorge Pérez et al. VarNameCollector optionalVarCollector = new VarNameCollector(); leftJoin.getRightArg().visit(optionalVarCollector); if (leftJoin.hasCondition()) { leftJoin.getCondition().visit(optionalVarCollector); } Set<String> problemVars = optionalVarCollector.getVarNames(); problemVars.removeAll(leftJoin.getLeftArg().getBindingNames()); problemVars.retainAll(bindings.getBindingNames()); if (problemVars.isEmpty()) { // left join is "well designed" return new LeftJoinIterator(this, leftJoin, bindings); } else { return new BadlyDesignedLeftJoinIterator(this, leftJoin, bindings, problemVars); } }
super.meet(leftJoin); TupleExpr leftArg = leftJoin.getLeftArg(); TupleExpr rightArg = leftJoin.getRightArg(); ValueExpr condition = leftJoin.getCondition(); leftJoin.replaceWith(leftArg); leftJoin.replaceWith(leftArg); leftJoin.replaceWith(leftArg); leftJoin.replaceWith(leftArg); leftJoin.setCondition(null);
/** * @inheritDoc */ @Override public void meet(LeftJoin theJoin) throws Exception { ctxOpen(theJoin); // try and reverse engineer the original scoping intent of the query final boolean aNeedsNewScope = theJoin.getParentNode() != null && (theJoin.getParentNode() instanceof Join || theJoin.getParentNode() instanceof LeftJoin); if (aNeedsNewScope) { mJoinBuffer.append("{\n"); } theJoin.getLeftArg().visit(this); mJoinBuffer.append(indent()).append("OPTIONAL {\n"); mIndent += 2; theJoin.getRightArg().visit(this); if (theJoin.getCondition() != null) { mJoinBuffer.append(indent()).append("filter").append( renderValueExpr(theJoin.getCondition())).append("\n"); } mIndent -= 2; mJoinBuffer.append(indent()).append("}.\n"); if (aNeedsNewScope) { mJoinBuffer.append("}.\n"); } ctxClose(theJoin); }
@Override public void meet(LeftJoin node) { super.meet(node); if (node.getCondition() != null) { List<ValueExpr> conjunctiveConstraints = new ArrayList<ValueExpr>(16); getConjunctiveConstraints(node.getCondition(), conjunctiveConstraints); TupleExpr arg = node.getRightArg(); ValueExpr condition = null; for (ValueExpr constraint : conjunctiveConstraints) { if (isWithinBindingScope(constraint, arg)) { arg = new Filter(arg, constraint); } else if (condition == null) { condition = constraint; } else { condition = new And(condition, constraint); } } node.setCondition(condition); node.setRightArg(arg); } }
@Override public void meet(final LeftJoin leftJoin) { if (leftJoin.getLeftArg().getBindingNames().containsAll(filterVars)) { leftJoin.getLeftArg().visit(this); } else { relocate(filter, leftJoin.getLeftArg()); } }
LeftJoin lj = new LeftJoin(); lj.setLeftArg(aLeft); lj.setRightArg(aExpr);
join.setLeftArg(leftJoin.getLeftArg()); leftJoin.setLeftArg(join); leftJoin.visit(this); join.setRightArg(leftJoin.getLeftArg()); leftJoin.setLeftArg(join); leftJoin.visit(this);
nextRightIter = rightIter = strategy.evaluate(join.getRightArg(), leftBindings); if (join.getCondition() == null) { return rightBindings; scopeBindings.retainAll(scopeBindingNames); if (strategy.isTrue(join.getCondition(), scopeBindings)) { return rightBindings;
Join join = new Join(bindings, binary.getLeftArg()); binary.setLeftArg(join);
public LeftJoinIterator(EvaluationStrategy strategy, LeftJoin join, BindingSet bindings) throws QueryEvaluationException { this.strategy = strategy; this.join = join; this.scopeBindingNames = join.getBindingNames(); leftIter = strategy.evaluate(join.getLeftArg(), bindings); // Initialize with empty iteration so that var is never null rightIter = new EmptyIteration<BindingSet, QueryEvaluationException>(); }
BinaryTupleOperator aJoin = aGroup.isOptional() ? new LeftJoin() : new Join(); ((LeftJoin)aJoin).setCondition(aBasicGroup.filtersAsAnd());
}, leftJoin.getRightArg(), leftBindings);
private static TupleExpr getJoin(TupleExpr oldJoin, TupleExpr newArg) { if (newArg instanceof FlattenedOptional) { return new LeftJoin(oldJoin, ((FlattenedOptional) newArg).getRightArg()); } else { return new Join(oldJoin, newArg); } }
public LeftJoin(TupleExpr leftArg, TupleExpr rightArg, ValueExpr condition) { this(leftArg, rightArg); setCondition(condition); }
public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(LeftJoin leftJoin, final BindingSet bindings) throws QueryEvaluationException { if (TupleExprs.containsSubquery(leftJoin.getRightArg())) { return new HashJoinIteration(this, leftJoin, bindings); } // Check whether optional join is "well designed" as defined in section // 4.2 of "Semantics and Complexity of SPARQL", 2006, Jorge Pérez et al. VarNameCollector optionalVarCollector = new VarNameCollector(); leftJoin.getRightArg().visit(optionalVarCollector); if (leftJoin.hasCondition()) { leftJoin.getCondition().visit(optionalVarCollector); } Set<String> problemVars = optionalVarCollector.getVarNames(); problemVars.removeAll(leftJoin.getLeftArg().getBindingNames()); problemVars.retainAll(bindings.getBindingNames()); if (problemVars.isEmpty()) { // left join is "well designed" return new LeftJoinIterator(this, leftJoin, bindings); } else { return new BadlyDesignedLeftJoinIterator(this, leftJoin, bindings, problemVars); } }