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 = -1; }
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 = -1; }
@Override public boolean equals(Object other) { if (other instanceof MultiProjection && super.equals(other)) { MultiProjection o = (MultiProjection)other; return projections.equals(o.getProjections()); } return false; }
@Override public ImmutableList<ProjectionElemList> getProjectionElemList() { if (projection instanceof Projection) { return ImmutableList.of(((Projection) projection).getProjectionElemList()); } else if (projection instanceof MultiProjection) { return ImmutableList.copyOf(((MultiProjection) projection).getProjections()); } else return ImmutableList.of(); }
@Override public boolean equals(Object other) { if (other instanceof MultiProjection && super.equals(other)) { MultiProjection o = (MultiProjection)other; return projections.equals(o.getProjections()); } return false; }
@Override public MultiProjection clone() { MultiProjection clone = (MultiProjection)super.clone(); clone.projections = new ArrayList<>(getProjections().size()); for (ProjectionElemList pe : getProjections()) { clone.addProjection(pe.clone()); } return clone; } }
@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; } }
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); }
final List<ProjectionElemList> projections = multiProjection.getProjections(); final BindingSet prev[] = new BindingSet[projections.size()]; evaluateTupleExpr(new BindingSetPipe(parent) {
@Override public void meet(MultiProjection projection) { List<ExtensionElem> bindings; if (projection.getArg() instanceof Extension) { bindings = ((Extension) projection.getArg()).getElements(); } else { bindings = Arrays.asList(); } for (ProjectionElemList template : projection.getProjections()) { recordConsequent(template, bindings); } }
/** * 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); }
@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 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; }
projections.add(((Projection) unary).getProjectionElemList()); } else { projections.addAll(((MultiProjection)unary).getProjections());