@Override public boolean equals(Object other) { if (other instanceof UnaryTupleOperator) { UnaryTupleOperator o = (UnaryTupleOperator)other; return arg.equals(o.getArg()); } return false; }
@Override protected void meetUnaryTupleOperator(UnaryTupleOperator node) { node.getArg().visit(this); }
public Set<String> getBindingNames() { return getArg().getBindingNames(); }
public Set<String> getAssuredBindingNames() { return getArg().getAssuredBindingNames(); }
@Override protected void meetNode(final QueryModelNode node) { // By default, do not traverse assert node instanceof TupleExpr; if (node instanceof UnaryTupleOperator) { if (((UnaryTupleOperator) node).getArg().getBindingNames() .containsAll(filterVars)) { ((UnaryTupleOperator) node).getArg().visit(this); } } relocate(filter, (TupleExpr) node); }
while (queryNode instanceof UnaryTupleOperator) { nodes.add((UnaryTupleOperator) queryNode); queryNode = ((UnaryTupleOperator) queryNode).getArg();
@Override protected void meetUnaryTupleOperator(UnaryTupleOperator node) { assert former == node.getArg(); if (replacement == null) { removeNode(node); } else { node.setArg((TupleExpr)replacement); } }
@Override public void meetOther(QueryModelNode node) { if (node instanceof PeriodicQueryNode) { PeriodicQueryNode pNode = (PeriodicQueryNode) node; // do nothing if PeriodicQueryNode already positioned correctly if (pNode.equals(relocationParent.getArg())) { return; } // remove node from query pNode.replaceWith(pNode.getArg()); // set node' child to be relocationParent's child pNode.setArg(relocationParent.getArg()); // add node back into query below relocationParent relocationParent.replaceChildNode(relocationParent.getArg(), pNode); } } }
@Override protected void meetUnaryTupleOperator(UnaryTupleOperator node) { handleChild(SeRQO.ARG, node.getArg()); super.meetUnaryTupleOperator(node); }
@Override public UnaryTupleOperator clone() { UnaryTupleOperator clone = (UnaryTupleOperator)super.clone(); clone.setArg(getArg().clone()); return clone; } }
private void addSourceExpressions(UnaryTupleOperator op, Collection<ProjectionElem> elems) { Extension ext = null; for (ProjectionElem projElem : elems) { ExtensionElem extElem = projElem.getSourceExpression(); if (extElem != null) { if (ext == null) { ext = new Extension(op.getArg()); op.setArg(ext); } ext.addElement(extElem); } } }
@Override protected void meetUnaryTupleOperator(UnaryTupleOperator node) throws RepositoryException { super.meetUnaryTupleOperator(node); RepositoryConnection owner = getSingleOwner(node.getArg()); if (owner != null) { node.replaceWith(new OwnedTupleExpr(owner, node.clone())); } }
@Override protected void meetUnaryTupleOperator(UnaryTupleOperator node) throws RepositoryException { super.meetUnaryTupleOperator(node); RepositoryConnection owner = getSingleOwner(node.getArg()); if (owner != null) { node.replaceWith(new OwnedTupleExpr(owner, node.clone())); } }
if (varsBefore.contains(name)) { UnaryTupleOperator proj = (UnaryTupleOperator)projElems.getParentNode(); Extension ext = new Extension(proj.getArg()); proj.setArg(ext); Var lostVar = new Var(name);
final QueryModelNode grandChild = unary.getArg(); Preconditions.checkArgument(grandChild instanceof Extension); final Extension extension = (Extension) grandChild;
@Override public void meet(Reduced node) throws RuntimeException { TupleExpr child = node.getArg(); if(!isSupported(child) && child instanceof UnaryTupleOperator) { UnaryTupleOperator replacement = (UnaryTupleOperator)child.clone(); // switch positions of child and node node.replaceWith(replacement); node.setArg(((UnaryTupleOperator) child).getArg().clone()); replacement.setArg(node.clone()); // visit the newly inserted replacement node (i.e. the clone of child now containing the old "node" as // child, so "node" can be bubbled down further if needed) replacement.visit(this); } }
@Override public void meet(Slice node) throws RuntimeException { TupleExpr child = node.getArg(); if(!isSupported(child) && child instanceof UnaryTupleOperator) { UnaryTupleOperator replacement = (UnaryTupleOperator)child.clone(); // switch positions of child and node node.replaceWith(replacement); node.setArg(((UnaryTupleOperator) child).getArg().clone()); replacement.setArg(node.clone()); // visit the newly inserted replacement node (i.e. the clone of child now containing the old "node" as // child, so "node" can be bubbled down further if needed) replacement.visit(this); } }
@Override public void meet(Distinct node) throws RuntimeException { TupleExpr child = node.getArg(); if(!isSupported(child) && child instanceof UnaryTupleOperator) { UnaryTupleOperator replacement = (UnaryTupleOperator)child.clone(); // switch positions of child and node node.replaceWith(replacement); node.setArg(((UnaryTupleOperator) child).getArg().clone()); replacement.setArg(node.clone()); // visit the newly inserted replacement node (i.e. the clone of child now containing the old "node" as // child, so "node" can be bubbled down further if needed) replacement.visit(this); } }
private TupleExpr visitHaving(Resource having) throws OpenRDFException { UnaryTupleOperator op = (UnaryTupleOperator)group.getParentNode(); op.setArg(new Extension(group)); Iteration<? extends Resource, QueryEvaluationException> iter = Statements.listResources(having, store); while (iter.hasNext()) { Resource r = iter.next(); ValueExpr havingExpr = visitExpression(r); Filter filter = new Filter(op.getArg(), havingExpr); op.setArg(filter); op = filter; } return op; }