示例#1
0
  @Override
  public void visit(OrExpression oe) {
    visitBinaryOperation(oe);

    Predicate right = _predStack.pop();
    Predicate left = _predStack.pop();

    Predicate or = new OrPredicate(left, right);
    _predStack.push(or);
  }
示例#2
0
  /*
   * Each of these operations create a Squall type, that's why so much similar code
   */
  @Override
  public void visit(Addition adtn) {
    visitBinaryOperation(adtn);

    ValueExpression right = _exprStack.pop();
    ValueExpression left = _exprStack.pop();

    ValueExpression add = new plan_runner.expressions.Addition(left, right);
    _exprStack.push(add);
  }
示例#3
0
  @Override
  public void visit(MinorThan mt) {
    visitBinaryOperation(mt);

    ValueExpression right = _exprStack.pop();
    ValueExpression left = _exprStack.pop();

    ComparisonPredicate cp = new ComparisonPredicate(ComparisonPredicate.LESS_OP, left, right);
    _predStack.push(cp);
  }
示例#4
0
  @Override
  public void visit(AndExpression ae) {
    visitBinaryOperation(ae);

    Predicate right = _predStack.pop();
    Predicate left = _predStack.pop();

    Predicate and = new AndPredicate(left, right);
    _predStack.push(and);
  }
示例#5
0
  @Override
  public void visit(NotEqualsTo net) {
    visitBinaryOperation(net);

    ValueExpression right = _exprStack.pop();
    ValueExpression left = _exprStack.pop();

    ComparisonPredicate cp = new ComparisonPredicate(ComparisonPredicate.NONEQUAL_OP, left, right);
    _predStack.push(cp);
  }
示例#6
0
  @Override
  public void visit(GreaterThanEquals gte) {
    visitBinaryOperation(gte);

    ValueExpression right = _exprStack.pop();
    ValueExpression left = _exprStack.pop();

    ComparisonPredicate cp = new ComparisonPredicate(ComparisonPredicate.NONLESS_OP, left, right);
    _predStack.push(cp);
  }
示例#7
0
  @Override
  public void visit(LikeExpression le) {
    visitBinaryOperation(le);

    ValueExpression right = _exprStack.pop();
    ValueExpression left = _exprStack.pop();

    LikePredicate lp = new LikePredicate(left, right);
    _predStack.push(lp);
  }
示例#8
0
  @Override
  public void visit(Subtraction s) {
    visitBinaryOperation(s);

    ValueExpression right = _exprStack.pop();
    ValueExpression left = _exprStack.pop();

    ValueExpression sub = new plan_runner.expressions.Subtraction(left, right);
    _exprStack.push(sub);
  }
示例#9
0
  @Override
  public void visit(Division dvsn) {
    visitBinaryOperation(dvsn);

    ValueExpression right = _exprStack.pop();
    ValueExpression left = _exprStack.pop();

    ValueExpression division = new plan_runner.expressions.Division(left, right);
    _exprStack.push(division);
  }
示例#10
0
  @Override
  public void visit(Multiplication m) {
    visitBinaryOperation(m);

    ValueExpression right = _exprStack.pop();
    ValueExpression left = _exprStack.pop();

    ValueExpression mult = new plan_runner.expressions.Multiplication(left, right);
    _exprStack.push(mult);
  }
示例#11
0
  @Override
  public void visit(Function function) {
    // all aggregate functions (SUM, AVG, COUNT, MAX, MIN) have only one parameter (Expression)
    // although COUNT(*) has no parameters
    // EXTRACT_YEAR has one parameter
    // if you change this method, NameProjectVisitor.visit(Function) has to be changed as well
    ExpressionList params = function.getParameters();
    int numParams = 0;
    if (params != null) {
      params.accept(this);

      // in order to determine the size
      List<Expression> listParams = params.getExpressions();
      numParams = listParams.size();
    }
    List<ValueExpression> expressions = new ArrayList<ValueExpression>();
    for (int i = 0; i < numParams; i++) {
      expressions.add(_exprStack.pop());
    }
    Collections.reverse(expressions); // at the stack top is the lastly added VE

    String fnName = function.getName();
    if (fnName.equalsIgnoreCase("EXTRACT_YEAR")) {
      if (numParams != 1) {
        throw new RuntimeException("EXTRACT_YEAR function has exactly one parameter!");
      }
      ValueExpression expr = expressions.get(0);
      ValueExpression ve = new IntegerYearFromDate(expr);
      _exprStack.push(ve);
    }
  }