@Override protected BindingSet convert(BindingSet sourceBindings) throws QueryEvaluationException { return project(projection.getProjectionElemList(), sourceBindings, parentBindings, !isOuterProjection); }
@Override public String getSignature() { return "(External Projection) " + Joiner.on(", ").join(tupleExpr.getProjectionElemList().getElements()).replaceAll("\\s+", " "); }
@Override public String getSignature() { return "(Mongo PcjQueryNode) " + Joiner.on(", ").join(super.getTupleExpr().getProjectionElemList().getElements()).replaceAll("\\s+", " "); } }
@Override public String getSignature() { return "(SimpleExternalTupleSet) " + Joiner.on(", ") .join(this.getTupleExpr().getProjectionElemList() .getElements()).replaceAll("\\s+", " "); } }
/** * Make a {@link ProjectionEvaluator} that processes the logic of a {@link Projection}. * * @param projection - Defines the projection that will be processed. (not null) * @return A {@link ProjectionEvaluator} for the provided {@link Projection}. */ public static ProjectionEvaluator make(final Projection projection) { requireNonNull(projection); final ProjectionElemList projectionElems = projection.getProjectionElemList(); final TupleExpr arg = projection.getArg(); final Optional<Extension> extension = arg instanceof Extension ? Optional.of((Extension)arg) : Optional.empty(); return new ProjectionEvaluator(projectionElems, extension); }
private Set<String> getProjectedVariables(TupleExpr expr) { if(expr instanceof Projection) { Projection projection = (Projection)expr; Set<String> projectedVars = new HashSet<>(); for (ProjectionElem elem : projection.getProjectionElemList().getElements()) { projectedVars.add(elem.getSourceName()); } return projectedVars; } else { return Collections.EMPTY_SET; } } }
@Override public void meet(Projection node) throws RuntimeException { for(ProjectionElem elem : node.getProjectionElemList().getElements()) { if(elem.getSourceName().equals(needle)) { found = true; } } // stop at projection, subquery }
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); }
@Override public boolean equals(Object other) { if (other instanceof Projection && super.equals(other)) { Projection o = (Projection)other; return projElemList.equals(o.getProjectionElemList()); } return false; }
@Override public void meet(Projection node) { handleType(SeRQO.PROJECTION); handleChild(SeRQO.ELEMENT, node.getProjectionElemList()); super.meet(node); }
public SQLSubQuery(String alias, Projection query, BindingSet bindings, Dataset dataset, ValueConverter converter, KiWiDialect dialect, Set<String> parentProjectedVars) throws UnsatisfiableQueryException { super(alias); Set<String> projectedVars = new HashSet<>(parentProjectedVars); // count projected variables for(ProjectionElem elem : query.getProjectionElemList().getElements()) { projectedVars.add(elem.getSourceName()); } // we build a full subquery for each of the UNION's arguments builder = new SQLBuilder(query.getArg(), bindings, dataset, converter, dialect, projectedVars); for(SQLVariable svl : builder.getVariables().values()) { if(projectedVars.contains(svl.getSparqlName())) { variables.add(svl); } } }
@Override public Projection clone() { Projection clone = (Projection)super.clone(); clone.setProjectionElemList(getProjectionElemList().clone()); return clone; }
@Override public void meet(Var node) { if (projection != null) { boolean projected = false; for (ProjectionElem e : projection.getProjectionElemList().getElements()) { String source = e.getSourceName(); String target = e.getTargetName(); if (node.getName().equals(source) && node.getName().equals(target)) { projected = true; break; } } if (!projected) { variablesProjected = false; } } }
@Override public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Projection projection, BindingSet bindings) throws QueryEvaluationException { // count projected variables if(isSupported(projection.getArg())) { for (ProjectionElem elem : projection.getProjectionElemList().getElements()) { projectedVars.add(elem.getSourceName()); } } return super.evaluate(projection, bindings); }
private TupleExpr getTupleExpr(ParsedQuery query) { TupleExpr tupleExpr = query.getTupleExpr(); if (tupleExpr instanceof Projection) { Projection proj = (Projection) tupleExpr; for (ProjectionElem e : proj.getProjectionElemList().getElements()) { if (!e.getSourceName().equals(e.getTargetName())) return proj; } return proj.getArg(); } return tupleExpr; }
@Override public void meet(Projection projectionNode) throws Exception { projectionNode.visitChildren(this); if (projectionNode.getArg() instanceof AggregationPipelineQueryNode && projectionNode.getParentNode() != null) { AggregationPipelineQueryNode pipelineNode = (AggregationPipelineQueryNode) projectionNode.getArg(); if (pipelineNode.project(Arrays.asList(projectionNode.getProjectionElemList()))) { projectionNode.replaceWith(pipelineNode); } } }
@Override public void meet(Projection node) throws RepositoryException { TupleExpr arg = node.getArg(); if (arg instanceof StatementPattern && arg.getBindingNames().equals(node.getBindingNames())) { meetNode(node); } else { arg.visit(this); if (patternNode == null) return; Map<String, String> map = new HashMap<String, String>(); for (ProjectionElem e : node.getProjectionElemList().getElements()) { String source = variables.get(e.getSourceName()); if (source == null) { source = safe(e.getSourceName()); } map.put(e.getTargetName(), source); } this.variables = map; this.patternNode = node; } }
@Override public void meet(Projection node) throws RuntimeException { super.meet(node); if (node.getArg() instanceof SelectQuery) { SelectQuery query = (SelectQuery)node.getArg(); Map<String, String> bindingVars = new HashMap<String, String>(); List<SelectProjection> selection = new ArrayList<SelectProjection>(); ProjectionElemList list = node.getProjectionElemList(); for (ProjectionElem e : list.getElements()) { String source = e.getSourceName(); String target = e.getTargetName(); bindingVars.put(target, source); SelectProjection s = query.getSelectProjection(source); if (s != null) { selection.add(s); } } query.setBindingVars(bindingVars); query.setSqlSelectVar(selection); node.replaceWith(query); } }
@Override public void meet(Projection node) throws RepositoryException { TupleExpr arg = node.getArg(); if (arg instanceof StatementPattern && arg.getBindingNames().equals(node.getBindingNames())) { meetNode(node); } else { arg.visit(this); if (patternNode == null) { return; } Map<String, String> map = new HashMap<String, String>(); for (ProjectionElem e : node.getProjectionElemList().getElements()) { String source = variables.get(e.getSourceName()); if (source == null) { source = safe(e.getSourceName()); } map.put(e.getTargetName(), source); } this.variables = map; this.patternNode = node; } }
@Override public void meet(Projection node) throws RDFHandlerException { ExtensionContext oldInlineBindings = meetExtension(node.getArg()); if (isSubQuery) { listEntry(); handler.handleStatement(valueFactory.createStatement(subject, RDF.TYPE, SP.SUB_QUERY_CLASS)); Resource queryBNode = valueFactory.createBNode(); handler.handleStatement(valueFactory.createStatement(subject, SP.QUERY_PROPERTY, queryBNode)); subject = queryBNode; handler.handleStatement(valueFactory.createStatement(subject, RDF.TYPE, SP.SELECT_CLASS)); } node.getProjectionElemList().visit(this); visitWhere(node.getArg()); node.getArg().visit(new GroupVisitor()); node.getArg().visit(new OrderVisitor()); inlineBindings = oldInlineBindings; hasGroup = false; }