private TupleExpr asJoin(Collection<TupleExpr> theList) { Join aJoin = new Join(); if (theList.isEmpty()) { throw new RuntimeException("Can't have an empty or missing join."); } else if (theList.size() == 1) { return theList.iterator().next(); } for (TupleExpr aExpr : theList) { if (aJoin.getLeftArg() == null) { aJoin.setLeftArg(aExpr); } else if (aJoin.getRightArg() == null) { aJoin.setRightArg(aExpr); } else { Join aNewJoin = new Join(); aNewJoin.setLeftArg(aJoin); aNewJoin.setRightArg(aExpr); aJoin = aNewJoin; } } return aJoin; }
@Override public void meet(final Join node) throws Exception { super.meet(node); final TupleExpr leftArg = node.getLeftArg(); final TupleExpr rightArg = node.getRightArg(); /** * if join(join(1, 2), join(3,4)) * should be: * join(join(join(1,2), 3), 4) */ if (leftArg instanceof Join && rightArg instanceof Join) { final Join leftJoin = (Join) leftArg; final Join rightJoin = (Join) rightArg; final TupleExpr right_LeftArg = rightJoin.getLeftArg(); final TupleExpr right_rightArg = rightJoin.getRightArg(); final Join inner = new Join(leftJoin, right_LeftArg); final Join outer = new Join(inner, right_rightArg); node.replaceWith(outer); } } }
public HashJoinIteration(EvaluationStrategy strategy, Join join, BindingSet bindings) throws QueryEvaluationException { this(strategy, join.getLeftArg(), join.getRightArg(), bindings, false); }
@Override public void meet(Join node) { if (compSet.contains(node.getRightArg())) { this.toBeReplaced = node.getRightArg(); node.replaceChildNode(node.getRightArg(), replacement); return; } else if (compSet.contains(node.getLeftArg())) { this.toBeReplaced = node.getLeftArg(); node.replaceChildNode(node.getLeftArg(), replacement); return; } else { super.meet(node); } }
private TupleExpr join(TupleExpr node, TupleExpr toMove) { toMove.replaceWith(new SingletonSet()); if (node != null) { node = new Join(node, toMove); } else { node = toMove; } return node; }
@Override public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Join join, BindingSet bindings) throws QueryEvaluationException { if (performant) { TupleExpr buffer = join.getLeftArg(); if (join.getRightArg() instanceof StatementPattern) { TupleExpr stmtPat = join.getRightArg(); } else if (join.getRightArg() instanceof ExternalBatchingIterator) { TupleExpr stmtPat = join.getRightArg(); } else if (join.getRightArg() instanceof Filter) { Filter filter = (Filter) join.getRightArg(); TupleExpr filterChild = filter.getArg(); if (filterChild instanceof StatementPattern) { } else if (filterChild instanceof Join) { Join filterChildJoin = (Join) filterChild; TupleExpr fcj_left = filterChildJoin.getLeftArg(); TupleExpr fcj_right = filterChildJoin.getRightArg(); return new FilterIterator(filter, new MultipleBindingSetsIterator(this, new Join(buffer, fcj_left), (StatementPattern) fcj_right, bindings), this);
private TupleExpr groupAsJoin(List<Group> theList) { BinaryTupleOperator aJoin = new Join(); Join aNewJoin = new Join(); aNewJoin.setLeftArg(aJoin); aNewJoin.setRightArg(aExpr);
@Override public void meet(Join queryNode) { // if query tree contains external tuples and they are not // positioned above statement pattern node // reposition if (this.extTuples.size() > 0 && !(queryNode.getRightArg() instanceof ExternalTupleSet) && !(queryNode.getRightArg() instanceof BindingSetAssignment)) { if (queryNode.getLeftArg() instanceof ExternalTupleSet) { QueryModelNode temp = queryNode.getLeftArg(); queryNode.setLeftArg(queryNode.getRightArg()); queryNode.setRightArg((TupleExpr)temp); } else { QNodeExchanger qnev = new QNodeExchanger(queryNode.getRightArg(), this.extTuples); queryNode.visit(qnev); queryNode.replaceChildNode(queryNode.getRightArg(), qnev.getReplaced()); super.meet(queryNode); } } else { super.meet(queryNode); } }
@Override public void meet(Join join) { super.meet(join); TupleExpr leftArg = join.getLeftArg(); TupleExpr rightArg = join.getRightArg(); if (leftArg instanceof EmptySet || rightArg instanceof EmptySet) { join.replaceWith(new EmptySet()); } else if (leftArg instanceof SingletonSet) { join.replaceWith(rightArg); } else if (rightArg instanceof SingletonSet) { join.replaceWith(leftArg); } }
if (join.getRightArg() instanceof StatementPattern) { join.getLeftArg().visit(this); if (join.getLeftArg() instanceof AggregationPipelineQueryNode) { pipelineNode = (AggregationPipelineQueryNode) join.getLeftArg(); joinWithSP = (StatementPattern) join.getRightArg(); else if (join.getLeftArg() instanceof StatementPattern) { join.getRightArg().visit(this); if (join.getRightArg() instanceof AggregationPipelineQueryNode) { pipelineNode = (AggregationPipelineQueryNode) join.getRightArg(); joinWithSP = (StatementPattern) join.getLeftArg(); join.visitChildren(this); join.replaceWith(pipelineNode);
TupleExpr replacement = orderedJoinArgs.get(i); for (i++; i < orderedJoinArgs.size(); i++) { replacement = new Join(replacement, orderedJoinArgs.get(i)); node.replaceWith(replacement); } finally { boundVars = origBoundVars;
@Override public void meet(final Join node) { final QueryModelNode lNode = node.getLeftArg(); if (lNode instanceof StatementPattern) { exchangeVar.replaceWith(lNode); node.setLeftArg(exchangeVar); } else { super.meet(node); } } }
public ParallelJoinIterator(EvaluationStrategy strategy, Join join, BindingSet bindings, ExecutorService executorService, int batch) throws QueryEvaluationException { this.strategy = strategy; this.join = join; leftIter = strategy.evaluate(join.getLeftArg(), bindings); this.executorService = executorService; this.batch = batch; }
@Override public void meet(Join queryNode) { // if query tree contains external tuples and they are not // positioned above statement pattern node // reposition if (this.bsas.size() > 0 && !(queryNode.getRightArg() instanceof BindingSetAssignment)) { QNodeExchanger qnev = new QNodeExchanger(queryNode.getRightArg(), bsas); queryNode.visit(qnev); queryNode.replaceChildNode(queryNode.getRightArg(), qnev.getReplaced()); super.meet(queryNode); } else { super.meet(queryNode); } }
@Override public boolean push(BindingSet bs) throws InterruptedException { if (bs == null) { return parent.push(null); } else { joinsInProgress.incrementAndGet(); evaluateTupleExpr(parent, join.getRightArg(), bs); return true; } } }, join.getLeftArg(), bindings);
@Override public void meet(Join node) { List<TupleExpr> reOrder = reOrderMap.get(node); if (reOrder != null) { List<Filter> filterList = Lists.newArrayList(filterArgs.get(node)); node.replaceWith(getNewJoin(reOrder, getFilterChain(filterList))); for (TupleExpr te : reOrder) { if (!(te instanceof StatementPattern) && !(te instanceof ExternalTupleSet)) { te.visit(this); } } } super.meet(node); } }
public HashJoinIteration(EvaluationStrategy strategy, Join join, BindingSet bindings) throws QueryEvaluationException { this(strategy, join.getLeftArg(), join.getRightArg(), bindings, false); }
private TupleExpr join(TupleExpr node, TupleExpr toMove) { toMove.replaceWith(new SingletonSet()); if (node != null) { node = new Join(node, toMove); } else { node = toMove; } return node; }
@Override public void meet(final Filter node) throws Exception { super.meet(node); final ValueExpr condition = node.getCondition(); final TupleExpr arg = node.getArg(); if (!(arg instanceof Join)) { return; } final Join join = (Join) arg; final TupleExpr leftArg = join.getLeftArg(); final TupleExpr rightArg = join.getRightArg(); if (leftArg instanceof StatementPattern && rightArg instanceof StatementPattern) { final Filter left = new Filter(leftArg, condition); final Filter right = new Filter(rightArg, condition); node.replaceWith(new Join(left, right)); } } }
private TupleExpr groupAsJoin(List<Group> theList) { BinaryTupleOperator aJoin = new Join(); Join aNewJoin = new Join(); aNewJoin.setLeftArg(aJoin); aNewJoin.setRightArg(aExpr);