/** * Creates a new unary tuple operator. * * @param arg * The operator's argument, must not be <tt>null</tt>. */ public UnaryTupleOperator(TupleExpr arg) { setArg(arg); }
@Override public void replaceChildNode(QueryModelNode current, QueryModelNode replacement) { if (arg == current) { setArg((TupleExpr)replacement); } else { super.replaceChildNode(current, replacement); } }
@Override protected void meetUnaryTupleOperator(UnaryTupleOperator node) { if (predicate.equals(SeRQO.ARG)) { node.setArg((TupleExpr) model.get(object)); } else { super.meetUnaryTupleOperator(node); } }
@Override protected void meetUnaryTupleOperator(UnaryTupleOperator node) { assert former == node.getArg(); if (replacement == null) { removeNode(node); } else { node.setArg((TupleExpr)replacement); } }
@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); } } }
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; }
private UnaryTupleOperator visitTemplates(Resource templates) throws OpenRDFException { List<ProjectionElemList> projElemLists = new ArrayList<ProjectionElemList>(); Iteration<? extends Resource, QueryEvaluationException> iter = Statements.listResources(templates, store); while (iter.hasNext()) { Resource r = iter.next(); ProjectionElemList projElems = visitTemplate(r); projElemLists.add(projElems); } UnaryTupleOperator expr; if (projElemLists.size() > 1) { MultiProjection proj = new MultiProjection(); proj.setProjections(projElemLists); expr = proj; } else { Projection proj = new Projection(); proj.setProjectionElemList(projElemLists.get(0)); expr = proj; } Reduced reduced = new Reduced(); reduced.setArg(expr); tupleRoot = reduced; SingletonSet stub = new SingletonSet(); expr.setArg(stub); tupleNode = stub; return expr; }
UnaryTupleOperator proj = (UnaryTupleOperator)projElems.getParentNode(); Extension ext = new Extension(proj.getArg()); proj.setArg(ext); Var lostVar = new Var(name); Value value = bindings.getValue(name);
@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); } }