Exemplo n.º 1
0
  @Override
  public void visit(Function function) {
    boolean recognized = isRecognized(function);
    if (!recognized) {
      // try to extract SUM
      // parameters for COUNT are ignored, as explained in super
      final String fnName = function.getName();
      if (fnName.equalsIgnoreCase("SUM")) {
        recognized = isRecognized(function.getParameters());
        if (recognized) {
          final ValueExpression expr = popFromExprStack();
          createSum(expr, function.isDistinct());
        }
      } else if (fnName.equalsIgnoreCase("COUNT")) {
        final List<ValueExpression> expressions = new ArrayList<ValueExpression>();

        if (function.isDistinct()) {
          // putting something on stack only if isDistinct is set to
          // true
          recognized = isRecognized(function.getParameters());
          // it might happen that we put on stack something we don't
          // use
          // this is the case only when some exprs are recognized and
          // the others not
          if (recognized) {

            // create a list of expressions
            int numParams = 0;
            final ExpressionList params = function.getParameters();
            if (params != null) numParams = params.getExpressions().size();

            for (int i = 0; i < numParams; i++) expressions.add(popFromExprStack());
          }
        } else recognized = true;
        if (recognized)
          // finally, create CountAgg out of expressions (empty if
          // nonDistinct)
          createCount(expressions, function.isDistinct());
      }
    }
    if (!recognized)
      // normal call to parent
      super.visit(function);
  }
Exemplo n.º 2
0
 @Override
 public void visit(Addition adtn) {
   if (!isRecognized(adtn))
     // normal call to parent
     super.visit(adtn);
 }
Exemplo n.º 3
0
 @Override
 public void visit(Subtraction s) {
   if (!isRecognized(s))
     // normal call to parent
     super.visit(s);
 }
Exemplo n.º 4
0
 @Override
 public void visit(Parenthesis prnths) {
   if (!isRecognized(prnths))
     // normal call to parent
     super.visit(prnths);
 }
Exemplo n.º 5
0
 @Override
 public void visit(Multiplication m) {
   if (!isRecognized(m))
     // normal call to parent
     super.visit(m);
 }
Exemplo n.º 6
0
 @Override
 public void visit(Division dvsn) {
   if (!isRecognized(dvsn))
     // normal call to parent
     super.visit(dvsn);
 }