private static final Expr THIS_COL_VALUE = new Expr() {
+ @Override public boolean isPure() {
+ return false;
+ }
@Override protected Value eval(RowContext ctx) {
return ctx.getThisColumnValue();
}
return paramVals;
}
+ private static boolean arePure(List<Expr> exprs) {
+ for(Expr expr : exprs) {
+ if(!expr.isPure()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static boolean arePure(Expr... exprs) {
+ for(Expr expr : exprs) {
+ if(!expr.isPure()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
private static void literalStrToString(String str, StringBuilder sb) {
sb.append("\"")
.append(str.replace("\"", "\"\""))
return outerExpr;
}
+ public abstract boolean isPure();
+
protected abstract Value eval(RowContext ctx);
protected abstract void toExprString(StringBuilder sb, boolean isDebug);
_str = str;
}
+ @Override
+ public boolean isPure() {
+ return true;
+ }
+
@Override
protected Value eval(RowContext ctx) {
return _val;
_val = toLiteralValue(valType, value, sdf);
}
+ @Override
+ public boolean isPure() {
+ return true;
+ }
+
@Override
public Value eval(RowContext ctx) {
return _val;
_fieldName = fieldName;
}
+ @Override
+ public boolean isPure() {
+ return false;
+ }
+
@Override
public Value eval(RowContext ctx) {
return ctx.getRowValue(_collectionName, _objName, _fieldName);
_expr = expr;
}
+ @Override
+ public boolean isPure() {
+ return _expr.isPure();
+ }
+
@Override
protected Value eval(RowContext ctx) {
return _expr.eval(ctx);
_params = params;
}
+ @Override
+ public boolean isPure() {
+ return _func.isPure() && arePure(_params);
+ }
+
@Override
protected Value eval(RowContext ctx) {
return _func.eval(exprListToValues(_params, ctx));
_right = right;
}
+ @Override
+ public boolean isPure() {
+ return arePure(_left, _right);
+ }
+
public OpType getOp() {
return _op;
}
_expr = expr;
}
+ @Override
+ public boolean isPure() {
+ return _expr.isPure();
+ }
+
public OpType getOp() {
return _op;
}
_expr = expr;
}
+ @Override
+ public boolean isPure() {
+ return _expr.isPure();
+ }
+
public OpType getOp() {
return _op;
}
_exprs = exprs;
}
+ @Override
+ public boolean isPure() {
+ return super.isPure() && arePure(_exprs);
+ }
+
@Override
protected Value eval(RowContext ctx) {
return _op.eval(_expr.eval(ctx),
_endRangeExpr = endRangeExpr;
}
+ @Override
+ public boolean isPure() {
+ return _expr.isPure() && arePure(_startRangeExpr, _endRangeExpr);
+ }
+
public Expr getRight() {
return _endRangeExpr;
}