@Override public void meet(MultiProjection projectionNode) throws Exception { projectionNode.visitChildren(this); if (projectionNode.getArg() instanceof AggregationPipelineQueryNode && projectionNode.getParentNode() != null) { AggregationPipelineQueryNode pipelineNode = (AggregationPipelineQueryNode) projectionNode.getArg(); if (pipelineNode.project(projectionNode.getProjections())) { projectionNode.replaceWith(pipelineNode); } } }
@Override public MultiProjection clone() { MultiProjection clone = (MultiProjection)super.clone(); clone.projections = new ArrayList<ProjectionElemList>(getProjections().size()); for (ProjectionElemList pe : getProjections()) { clone.addProjection(pe.clone()); } return clone; } }
@Override public void meet(MultiProjection node) { if (predicate.equals(SeRQO.ELEMENTS)) { node.setProjections((List<ProjectionElemList>) model.get(object)); } else { super.meet(node); } }
@Override public void meet(MultiProjection node) throws RDFHandlerException { ExtensionContext oldInlineBindings = meetExtension(node.getArg()); ListContext ctx = startTemplateList(); isMultiProjection = true; for (ProjectionElemList proj : node.getProjections()) { proj.visit(this); } endTemplateList(ctx); isMultiProjection = false; visitWhere(node.getArg()); inlineBindings = oldInlineBindings; }
public MultiProjectionIterator(MultiProjection multiProjection, CloseableIteration<BindingSet, QueryEvaluationException> iter, BindingSet bindings) { this.projections = multiProjection.getProjections(); this.iter = iter; this.parentBindings = bindings; this.previousBindings = new BindingSet[projections.size()]; // initialize out-of-range to enforce a fetch of the first result upon // first use nextProjectionIdx = projections.size(); }
tuple = new Projection(tuple, projection); }else if (!projectionElements.isEmpty()){ tuple = new MultiProjection(tuple, projectionElements);
@Override public Set<String> getAssuredBindingNames() { Set<String> bindingNames = new HashSet<String>(); if (projections.size() >= 1) { Set<String> assuredSourceNames = getArg().getAssuredBindingNames(); bindingNames.addAll(projections.get(0).getTargetNamesFor(assuredSourceNames)); for (int i = 1; i < projections.size(); i++) { bindingNames.retainAll(projections.get(i).getTargetNamesFor(assuredSourceNames)); } } return bindingNames; }
private UnaryTupleOperator multiProjection() { MultiProjection aProjection = new MultiProjection(); aProjection.addProjection(aList); aProjection.setArg(aExt);
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; }
public void addProjections(Iterable<ProjectionElemList> projections) { for (ProjectionElemList projection : projections) { addProjection(projection); } }
@Override public boolean equals(Object other) { if (other instanceof MultiProjection && super.equals(other)) { MultiProjection o = (MultiProjection)other; return projections.equals(o.getProjections()); } return false; }
/** * Make a {@link MultiProjectionEvaluator} that processes the logic of a {@link MultiProjection}. * * @param multiProjection - Defines the projections that will be processed. (not null) * @param bNodeIdFactory - Creates the IDs for Blank Nodes. (not null) * @return A {@link MultiProjectionEvaluator} for the provided {@link MultiProjection}. */ public static MultiProjectionEvaluator make(final MultiProjection multiProjection, final BNodeIdFactory bNodeIdFactory) { requireNonNull(multiProjection); // Figure out if there are extensions. final TupleExpr arg = multiProjection.getArg(); final Optional<Extension> extension = (arg instanceof Extension) ? Optional.of((Extension)arg): Optional.empty(); // If there are, iterate through them and find any blank node source names. final Set<String> blankNodeSourceNames = new HashSet<>(); if(extension.isPresent()) { for(final ExtensionElem elem : extension.get().getElements()) { if(elem.getExpr() instanceof BNodeGenerator) { blankNodeSourceNames.add( elem.getName() ); } } } // Create a ProjectionEvaluator for each projection that is part of the multi. final Set<ProjectionEvaluator> projections = new HashSet<>(); for(final ProjectionElemList projectionElemList : multiProjection.getProjections()) { projections.add( new ProjectionEvaluator(projectionElemList, extension) ); } return new MultiProjectionEvaluator(projections, blankNodeSourceNames, bNodeIdFactory); }
result = new MultiProjection(result, projList);
@Override public void meet(MultiProjection node) throws QueryEvaluationException { TupleExpr arg = node.getArg(); if (arg instanceof Extension) { Extension extension = (Extension) arg; TupleExpr arg2 = extension.getArg(); if (arg2 instanceof SingletonSet) { evaluate(node); } } }
private static VariableOrder getConstructGraphVarOrder(final Reduced node) { //get child node final QueryModelNode child = node.getArg(); Preconditions.checkArgument(child instanceof Projection || child instanceof MultiProjection); final UnaryTupleOperator unary = (UnaryTupleOperator) child; //get ProjectionElemList to build ConstructGraph final List<ProjectionElemList> projections = new ArrayList<>(); if(unary instanceof Projection) { projections.add(((Projection) unary).getProjectionElemList()); } else { projections.addAll(((MultiProjection)unary).getProjections()); } return getConstructGraphVarOrder(projections); }
tuple = new Projection(tuple, projection); } else if (!projectionElements.isEmpty()) { tuple = new MultiProjection(tuple, projectionElements);
public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(MultiProjection multiProjection, BindingSet bindings) throws QueryEvaluationException { CloseableIteration<BindingSet, QueryEvaluationException> result; result = this.evaluate(multiProjection.getArg(), bindings); result = new MultiProjectionIterator(multiProjection, result, bindings); return result; }
@Override public void meet(MultiProjection node) { handleType(SeRQO.MULTIPROJECTION); handleChildList(SeRQO.ELEMENTS, node.getProjections()); super.meet(node); }
tuple = new Projection(tuple, projection); } else if (!projectionElements.isEmpty()) { tuple = new MultiProjection(tuple, projectionElements);
projections.add(((Projection) unary).getProjectionElemList()); } else { projections.addAll(((MultiProjection)unary).getProjections());