@Override public Union visit(UnionBlock expr, QueryMetadata md) { List<TupleExpr> tuples = new ArrayList<TupleExpr>(expr.getBlocks().size()); for (Block block : expr.getBlocks()) { tuples.add(toTuple(block, md)); } Union rv = new Union(tuples.get(0), tuples.get(1)); for (int i = 2; i < tuples.size(); i++) { rv = new Union(rv, tuples.get(i)); } return rv; }
/** * @inheritDoc */ @Override public void meet(Union theOp) throws Exception { binaryOpMeet(theOp, theOp.getLeftArg(), theOp.getRightArg()); }
Union tmp; Union first = new Union(); first.setLeftArg(unions.get(0)); first.setRightArg(unions.get(1)); last = first; tmp = new Union( last.getRightArg(), unions.get(i) ); last.setRightArg(tmp); last = tmp;
@Override public void meet(Union union) { super.meet(union); TupleExpr leftArg = union.getLeftArg(); TupleExpr rightArg = union.getRightArg(); if (leftArg instanceof EmptySet) { union.replaceWith(rightArg); } else if (rightArg instanceof EmptySet) { union.replaceWith(leftArg); } else if (leftArg instanceof SingletonSet && rightArg instanceof SingletonSet) { union.replaceWith(leftArg); } }
@Override public void meet(Union node) throws RepositoryException { super.meet(node); List<Owned<TupleExpr>> ows = new ArrayList<Owned<TupleExpr>>(); for (TupleExpr arg : new TupleExpr[] { node.getLeftArg(), node.getRightArg() }) { RepositoryConnection member = getSingleOwner(arg); int idx = ows.size() - 1; if (ows.size() > 0 && ows.get(idx).getOwner() == member) { TupleExpr union = ows.get(idx).getOperation(); union = new Union(union, arg.clone()); ows.get(idx).setOperation(union); } else { ows.add(new Owned<TupleExpr>(member, arg.clone())); } } addOwners(node, ows); }
@Override public void meet(Union union) { super.meet(union); TupleExpr leftArg = union.getLeftArg(); TupleExpr rightArg = union.getRightArg(); if (leftArg instanceof Join && rightArg instanceof Join) { Join leftJoinArg = (Join)leftArg; Join rightJoin = (Join)rightArg; if (leftJoinArg.getLeftArg().equals(rightJoin.getLeftArg())) { // factor out the left-most join argument Join newJoin = new Join(); union.replaceWith(newJoin); newJoin.setLeftArg(leftJoinArg.getLeftArg()); newJoin.setRightArg(union); union.setLeftArg(leftJoinArg.getRightArg()); union.setRightArg(rightJoin.getRightArg()); union.visit(this); } } } }
Join leftJoin = new Join(union.getLeftArg(), rightArg.clone()); Join rightJoin = new Join(union.getRightArg(), rightArg.clone()); Union newUnion = new Union(leftJoin, rightJoin); join.replaceWith(newUnion); newUnion.visit(this); Join leftJoin = new Join(leftArg.clone(), union.getLeftArg()); Join rightJoin = new Join(leftArg.clone(), union.getRightArg()); Union newUnion = new Union(leftJoin, rightJoin); join.replaceWith(newUnion); newUnion.visit(this);
Union union = new Union(); Union currentUnion = union; for (int i = 0; i < altCount - 1; i++) { pathAltNode.jjtGetChild(i).jjtAccept(this, data); TupleExpr arg = graphPattern.buildTupleExpr(); currentUnion.setLeftArg(arg); if (i == altCount - 2) { // second-to-last item graphPattern = new GraphPattern(parentGP); pathAltNode.jjtGetChild(i + 1).jjtAccept(this, data); arg = graphPattern.buildTupleExpr(); currentUnion.setRightArg(arg); Union newUnion = new Union(); currentUnion.setRightArg(newUnion); currentUnion = newUnion;
Union union = new Union(); Union currentUnion = union; currentUnion.setLeftArg(path); if (length == upperBound - 1) { path = createPath(scope, subjVar, te, endVar, contextVar, length + 1); currentUnion.setRightArg(path); Union nextUnion = new Union(); currentUnion.setRightArg(nextUnion); currentUnion = nextUnion; for (String name : union.getAssuredBindingNames()) { ProjectionElem pe = new ProjectionElem(name); pelist.addElement(pe);
private void addOwners(Union node, List<Owned<TupleExpr>> ows) { if (ows.size() == 1) { RepositoryConnection o = ows.get(0).getOwner(); if (o != null) { // every element is used by the same owner node.replaceWith(new OwnedTupleExpr(o, node.clone())); } } else { TupleExpr replacement = null; for (Owned<TupleExpr> e : ows) { RepositoryConnection o = e.getOwner(); TupleExpr union = e.getOperation(); if (o == null) { // multiple owners for (TupleExpr arg : getUnionArgs(union)) { replacement = replacement == null ? arg.clone() : new Union(replacement, arg.clone()); } } else { OwnedTupleExpr arg = new OwnedTupleExpr(o, union); replacement = replacement == null ? arg : new Union(replacement, arg); } } node.replaceWith(replacement); } }
@Override protected Iteration<BindingSet, QueryEvaluationException> createIteration() throws QueryEvaluationException { return evaluate(union.getLeftArg(), bindings); } };
@Override protected Iteration<BindingSet, QueryEvaluationException> createIteration() throws QueryEvaluationException { return evaluate(union.getRightArg(), bindings); } };
Var subjVar = sp.getSubjectVar(); Union union = new InferUnion(); union.setLeftArg(sp); union.setRightArg(new StatementPattern(objVar, predVar, subjVar, cntxtVar)); node.replaceWith(union);
@Override public void meet(Union union) { super.meet(union); TupleExpr leftArg = union.getLeftArg(); TupleExpr rightArg = union.getRightArg(); if (leftArg instanceof EmptySet) { union.replaceWith(rightArg); } else if (rightArg instanceof EmptySet) { union.replaceWith(leftArg); } else if (leftArg instanceof SingletonSet && rightArg instanceof SingletonSet) { union.replaceWith(leftArg); } }
@Override public void meet(Union node) throws RepositoryException { super.meet(node); List<Owned<TupleExpr>> ows = new ArrayList<Owned<TupleExpr>>(); for (TupleExpr arg : new TupleExpr[] { node.getLeftArg(), // NOPMD node.getRightArg() }) { RepositoryConnection member = getSingleOwner(arg); int idx = ows.size() - 1; if ((!ows.isEmpty()) && ows.get(idx).getOwner() == member) { TupleExpr union = ows.get(idx).getOperation(); union = new Union(union, arg.clone()); // NOPMD ows.get(idx).setOperation(union); } else { ows.add(new Owned<TupleExpr>(member, arg.clone())); // NOPMD } } addOwners(node, ows); }
StatementPattern sp = entry.getKey(); TupleFunction func = entry.getValue(); Union union = new Union(); sp.replaceWith(union); TupleExpr stmts = sp; objList = Collections.<ValueExpr> singletonList(sp.getObjectVar()); union.setLeftArg(stmts); union.setRightArg(magicPropertyNode);
private void addOwners(Union node, List<Owned<TupleExpr>> ows) { if (ows.size() == 1) { RepositoryConnection owner = ows.get(0).getOwner(); if (owner != null) { // every element is used by the same owner node.replaceWith(new OwnedTupleExpr(owner, node.clone())); } } else { TupleExpr replacement = null; for (Owned<TupleExpr> e : ows) { RepositoryConnection owner = e.getOwner(); TupleExpr union = e.getOperation(); if (owner == null) { // multiple owners for (TupleExpr arg : getUnionArgs(union)) { replacement = replacement == null ? arg.clone() : new Union(replacement, arg.clone()); // NOPMD } } else { OwnedTupleExpr arg = new OwnedTupleExpr(owner, union); // NOPMD replacement = replacement == null ? arg : new Union( // NOPMD replacement, arg); } } node.replaceWith(replacement); } }
private List<TupleExpr> getUnionArgs(TupleExpr union, List<TupleExpr> list) { if (union instanceof Union) { getUnionArgs(((Union)union).getLeftArg(), list); getUnionArgs(((Union)union).getLeftArg(), list); } else { list.add(union); } return list; }
Var subjVar = sp.getSubjectVar(); Union union = new InferUnion(); union.setLeftArg(sp); union.setRightArg(new StatementPattern(objVar, new Var(predVar.getName(), invPropUri), subjVar, cntxtVar)); node.replaceWith(union);
/** * @inheritDoc */ @Override public void meet(Union theOp) throws Exception { String aLeft = renderTupleExpr(theOp.getLeftArg()); String aRight = renderTupleExpr(theOp.getRightArg()); mBuffer.append(aLeft).append("\nunion\n").append(aRight); }