@Override public String toString() { return varNode.toString() ; } }
public String toPrefixString() { return varNode.toString() ; } // As an expression (aggregators override this).
public String asSparqlExpr() { return varNode.toString() ; }
protected String createPredicateFilter(final Var predicateVar) { String filter = ""; if(!ignoredProperties.isEmpty()) { filter += "FILTER("; if(USE_FILTER_IN) { filter += String.format( FILTER_NOT_IN_CLAUSE, predicateVar.toString(), ignoredProperties.stream() .map(p -> "<" + p + ">") .collect(Collectors.joining(","))); } else { filter += ignoredProperties.stream() .map(input -> predicateVar.toString() + " != <" + input + ">") .collect(Collectors.joining(" && ")); } filter += ")\n"; } if(!allowedPropertyNamespaces.isEmpty()){ filter += "FILTER(" + predicateVar + " = <" + RDF.type.getURI() + "> || "; filter += allowedPropertyNamespaces.stream() .map(ns -> "(STRSTARTS(STR(" + predicateVar + "),'" + ns + "'))") .collect(Collectors.joining(" || ")); filter += ")\n"; } return filter; }
/** * Creates a user defined function definition * @param uri Function URL * @param e Expression * @param argList Arguments */ public UserDefinedFunctionDefinition(String uri, Expr e, List<Var> argList) { this.uri = uri; this.expr = e; this.argList = new ArrayList<>(argList); //Verify that all mentioned variables are in the arguments list Set<Var> mentioned = this.expr.getVarsMentioned(); for (Var v : mentioned) { if (!argList.contains(v)) throw new ExprBuildException("Cannot use the variable " + v.toString() + " in the expression since it is not included in the argList argument. All variables must be arguments to the function"); } //If used variables is greater than argument variables this is an error if (mentioned.size() > this.argList.size()) throw new ExprBuildException("Mismatch between variables used in expression and number of variables in argument list, expected " + this.argList.size() + " but found " + mentioned.size()); //May have more arguments than used, however this only gives warning(s) if (mentioned.size() < this.argList.size()) { for (Var v : this.argList) { if (!mentioned.contains(v) && warnOnUnusedVariable) LOG.warn("Function <" + uri + "> has argument " + v + " which is never used in the expression"); } } }
void appendVarList(Query query, IndentedWriter sb, List<String> vars) { boolean first = true ; for ( String varName : vars ) { Var var = Var.alloc(varName) ; if ( ! first ) sb.print(" ") ; sb.print(var.toString()) ; first = false ; } }
@Override protected void details(IndentedWriter out, SerializationContext cxt) { out.print(Lib.className(this)) ; out.print(" ?"+var.toString()+" = "+FmtUtils.stringForNode(node, cxt)) ; } }
private void writeVarList(List<Var> vars) { start() ; boolean first = true ; for ( Var var : vars ) { if ( !first ) out.print(" ") ; first = false ; out.print(var.toString()) ; } finish() ; }
retval = Var.alloc(Var.canonical(o.toString())); if ("*".equals(Var.canonical(retval.toString()))) { return null;
private void writeNamedExprList(VarExprList project) { start() ; boolean first = true ; for ( Var v : project.getVars() ) { if ( !first ) out.print(" ") ; first = false ; Expr expr = project.getExpr(v) ; if ( expr != null ) { start() ; out.print(v.toString()) ; out.print(" ") ; WriterExpr.output(out, expr, sContext) ; finish() ; } else out.print(v.toString()) ; } finish() ; }
Var var = Var.alloc(varName); Cell cell = row.createCell(columns++); cell.setCellValue(var.toString()); vars.add(var);
retval = Var.alloc(Var.canonical(o.toString())); if ("*".equals(Var.canonical(retval.toString()))) { return null;
sep = SEP; Var var = Var.alloc(v); w.write(var.toString()); vars.add(var);
@Override protected void buildProject() { for ( Var v : getProject() ) { if ( ! v.isNamedVar() ) continue ; // Value scope == IdScope for layout1 // CHECK ScopeEntry e = getSqlExprNode().getIdScope().findScopeForVar(v) ; if ( e == null ) continue ; SqlColumn c = e.getColumn() ; String sqlVarName = allocSqlName(v) ; addProject(c, sqlVarName) ; addAnnotation(sqlVarName+"="+v.toString()) ; } setAnnotation() ; }
out.print(v.toString()) ;
first = false ; SqlColumn col = sqlNode.getIdScope().findScopeForVar(v).getColumn() ; out.print(v.toString()) ; SqlColumn leftCol = join.getLeft().getIdScope().findScopeForVar(v).getColumn() ; SqlColumn rightCol = join.getRight().getIdScope().findScopeForVar(v).getColumn() ; out.print(v.toString()) ;
@Override public void visit(OpGroup opGroup) { start(opGroup, NoNL) ; writeNamedExprList(opGroup.getGroupVars()) ; if ( !opGroup.getAggregators().isEmpty() ) { // --- Aggregators out.print(" ") ; start() ; out.incIndent() ; boolean first = true ; for ( ExprAggregator agg : opGroup.getAggregators() ) { if ( !first ) { out.print(" ") ; } first = false ; Var v = agg.getVar() ; String str = agg.getAggregator().toPrefixString() ; start() ; out.print(v.toString()) ; out.print(" ") ; out.print(str) ; finish() ; } finish() ; out.decIndent() ; } out.println() ; printOp(opGroup.getSubOp()) ; finish(opGroup) ; }
addProject(cType, vType) ; addAnnotation(sqlVarName+"="+v.toString()) ;