private void _setVar(Var v) { this.var = v ; this.exprVar = new ExprVar(var) ; }
public static Var applyVar(Var v, ExprTransform exprTransform) { if ( exprTransform == null ) return v ; ExprVar expr = new ExprVar(v) ; Expr e = exprTransform.transform(expr) ; if ( e instanceof ExprVar ) return ((ExprVar)e).asVar() ; throw new InternalErrorException("Managed to turn a variable " + v + " into " + e) ; }
public ExprVar normalize(ExprVar expr, Map<String, TypeToken> typeMap) { TypeToken datatype = typeMap.get(expr.getVarName()); if(datatype == null) { throw new RuntimeException("No datatype information for column " + expr.getVarName() + "; typeMap=" + typeMap); } return new ExprVar(datatype.getName()); }
public Expr _transform(ExprVar nv) { Expr tmp = map.get(nv.asVar()); return tmp != null ? tmp : nv; }
public SqlExpr translate(ExprVar expr, Map<Var, Expr> binding, Map<String, TypeToken> typeMap) { SqlExpr result; if(binding != null) { Var var = expr.asVar(); Expr definition = binding.get(var); result = translateX(definition, null, typeMap); } else { String varName = expr.getVarName(); TypeToken datatype = typeMap.get(varName); if(datatype == null) { throw new RuntimeException("No datatype found for " + varName); } result = new S_ColumnRef(datatype, varName); } return result; }
private Var(ExprVar v) { this(v.getVarName()) ; }
@Override public void visit(ExprVar nv) { String s = nv.getVarName() ; if ( Var.isBlankNodeVarName(s) ) { // Return to a bNode via the bNode mapping of a variable. Var v = Var.alloc(s) ; out.print(context.getBNodeMap().asString(v) ) ; } else { // Print in variable form or as an aggregator expression out.print(nv.asSparqlExpr()) ; } }
@Override public Expr transform(ExprVar exprVar) { return transform(exprVar.getAsNode()); }
@Override public void visit(ExprVar nv) { action.var(acc, nv.asVar()) ; } }
@Override public boolean equals(Expr other, boolean bySyntax) { if ( other == null ) return false ; if ( this == other ) return true ; if ( ! ( other instanceof ExprVar ) ) return false ; ExprVar nvar = (ExprVar)other ; return getVarName().equals(nvar.getVarName()) ; }
public SortCondition(Var var, int dir) { this(new ExprVar(var),dir) ; }
public static Var applyVar(Var v, ExprTransform exprTransform) { if ( exprTransform == null ) return v ; ExprVar expr = new ExprVar(v) ; Expr e = exprTransform.transform(expr) ; if ( e instanceof ExprVar ) return ((ExprVar)e).asVar() ; throw new InternalErrorException("Managed to turn a variable " + v + " into " + e) ; }
{ @Override public Expr transform(ExprVar exprVar) { return new ExprVar(exprVar.getVarName().toUpperCase()) ; } } ;
void info() { if ( opSlice != null ) System.out.printf("slice: (%d, %d)\n", opSlice.getStart(), opSlice.getLength()) ; if ( opDistinct != null ) System.out.printf("distinct\n") ; if ( opReduced != null ) System.out.printf("reduced\n") ; if ( opProject != null ) System.out.printf("project: %s\n", opProject.getVars()) ; if ( opOrder != null ) System.out.printf("order: %s\n", opOrder.getConditions()) ; if ( opHaving != null ) System.out.printf("having: %s\n", opHaving.getExprs()) ; if ( opExtends != null && !opExtends.isEmpty() ) { List<VarExprList> z = opExtends.stream().map(x -> x.getVarExprList()).collect(Collectors.toList()) ; System.out.printf("assigns: %s\n", z) ; } if ( opGroup != null ) { List<ExprAggregator> aggregators = opGroup.getAggregators() ; List<Var> aggVars = aggregators.stream().map(x -> x.getAggVar().asVar()).collect(Collectors.toList()) ; System.out.printf("group: %s |-| %s\n", opGroup.getGroupVars(), opGroup.getAggregators()) ; System.out.printf("group agg vars: %s\n", aggVars) ; } }
@Override public Expr transform(ExprVar exprVar) { //If variable matches replace with the chosen expression if (this.replacements.containsKey(exprVar.getVarName())) return this.replacements.get(exprVar.getVarName()); //Otherwise leave as is return super.transform(exprVar); }
public Expr copy(Var v) { return new ExprVar(v) ; }