Package plan_runner.expressions

Examples of plan_runner.expressions.ValueExpression


    final TypeConversion tc = _schema.getType(ParserUtil.getFullSchemaColumnName(column, _tan));

    // extract the position (index) of the required column
    final int position = _it.getColumnIndex(column, _affectedComponent);

    final ValueExpression ve = new ColumnReference(tc, position);
    _exprStack.push(ve);
  }
View Full Code Here


    throw new UnsupportedOperationException("Not supported yet.");
  }

  @Override
  public void visit(DateValue dv) {
    final ValueExpression ve = new ValueSpecification(_dateConv, dv.getValue());
    _exprStack.push(ve);
  }
View Full Code Here

  @Override
  public void visit(Division dvsn) {
    visitBinaryOperation(dvsn);

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

    final ValueExpression division = new plan_runner.expressions.Division(left, right);
    _exprStack.push(division);
  }
View Full Code Here

    _exprStack.push(division);
  }

  @Override
  public void visit(DoubleValue dv) {
    final ValueExpression ve = new ValueSpecification(_dblConv, dv.getValue());
    _exprStack.push(ve);
  }
View Full Code Here

  @Override
  public void visit(EqualsTo et) {
    visitBinaryOperation(et);

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

    final ComparisonPredicate cp = new ComparisonPredicate(ComparisonPredicate.EQUAL_OP, left,
        right);
    _predStack.push(cp);
  }
View Full Code Here

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

  @Override
  public void visit(GreaterThan gt) {
    visitBinaryOperation(gt);

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

    final ComparisonPredicate cp = new ComparisonPredicate(ComparisonPredicate.GREATER_OP,
        left, right);
    _predStack.push(cp);
  }
View Full Code Here

    if ((expr1 instanceof ColumnReference) || (expr1 instanceof ValueSpecification))
      return expr1;
    else {
      final List<ValueExpression> next = expr1.getInnerExpressions();

      ValueExpression toCombine1 = combine(expr1, 0, next.get(0));
      ValueExpression toCombine2 = combine(expr1, 1, next.get(1));

      if ((toCombine1 instanceof ValueSpecification)
          && (toCombine2 instanceof ValueSpecification)) {
        final Double result = new Double(expr1.evalString(null));
        final ValueExpression newExpr = new ValueSpecification<Double>(numConv, result);
        if (parent != null)
          parent.changeValues(index, newExpr);
        return newExpr;
      } else if ((!(toCombine1 instanceof ValueSpecification) && (toCombine2 instanceof ValueSpecification))
          || // Variable on the First one or the Second one
          ((toCombine1 instanceof ValueSpecification) && !(toCombine2 instanceof ValueSpecification))) {

        // Either way make toCombine1 variable have the Variable
        ValueExpression temp;
        if ((toCombine1 instanceof ValueSpecification)
            && !(toCombine2 instanceof ValueSpecification)) {
          temp = toCombine1;
          toCombine1 = toCombine2;
          toCombine2 = temp;
        }

        final List<ValueExpression> toComb1List = toCombine1.getInnerExpressions();

        ValueExpression clean, dirty;
        int cleanPartOfInner = 0;

        if (expr1 instanceof Multiplication) {
          ValueExpression multResult;

          if (toCombine1 instanceof Multiplication) {
            if (toComb1List.get(0) instanceof ValueSpecification) {
              clean = toComb1List.get(0);
              dirty = toComb1List.get(1);
            } else {
              clean = toComb1List.get(1);
              dirty = toComb1List.get(0);
              cleanPartOfInner = 1;
            }

            ValueExpression extraClean = new Multiplication<Double>(toCombine2, clean);
            extraClean = combine(null, 0, extraClean);
            multResult = new Multiplication<Double>(extraClean, dirty);
            return multResult;
          } else if (toCombine1 instanceof Addition) {
            if (toComb1List.get(0) instanceof ValueSpecification) {
              clean = toComb1List.get(0);
              dirty = toComb1List.get(1);
            } else {
              clean = toComb1List.get(1);
              dirty = toComb1List.get(0);
              cleanPartOfInner = 1;
            }
            ValueExpression extraClean = new Multiplication<Double>(toCombine2, clean);
            extraClean = combine(null, 0, extraClean);
            final ValueExpression variableCont = new Multiplication<Double>(toCombine2,
                dirty);
            multResult = new Addition<Double>(extraClean, variableCont);
            return multResult;
          } else if (toCombine1 instanceof Subtraction) {
            if (toComb1List.get(0) instanceof ValueSpecification) {
              clean = toComb1List.get(0);
              dirty = toComb1List.get(1);
            } else {
              clean = toComb1List.get(1);
              dirty = toComb1List.get(0);
              cleanPartOfInner = 1;
            }
            ValueExpression extraClean = new Multiplication<Double>(toCombine2, clean);
            extraClean = combine(null, 0, extraClean);
            final ValueExpression variableCont = new Multiplication<Double>(toCombine2,
                dirty);
            if (cleanPartOfInner == 0)
              multResult = new Subtraction<Double>(extraClean, variableCont);
            else
              multResult = new Subtraction<Double>(variableCont, extraClean);
            return multResult;
          } else if (toCombine1 instanceof ColumnReference)
            return expr1;
        } else if (expr1 instanceof Addition) {
          ValueExpression extraClean, finalAdd;
          if (toCombine1 instanceof Multiplication) {
            if (toComb1List.get(0) instanceof ValueSpecification) {
              clean = toComb1List.get(0);
              dirty = toComb1List.get(1);
            } else {
              clean = toComb1List.get(1);
              dirty = toComb1List.get(0);
              cleanPartOfInner = 1;
            }
            finalAdd = new Addition<Double>(toCombine1, toCombine2);
            return finalAdd;
          } else if (toCombine1 instanceof Addition) {
            if (toComb1List.get(0) instanceof ValueSpecification) {
              clean = toComb1List.get(0);
              dirty = toComb1List.get(1);
            } else {
              clean = toComb1List.get(1);
              dirty = toComb1List.get(0);
              cleanPartOfInner = 1;
            }
            extraClean = new Addition<Double>(toCombine2, clean);
            extraClean = combine(null, 0, extraClean);
            finalAdd = new Addition<Double>(extraClean, dirty);
            return finalAdd;
          } else if (toCombine1 instanceof Subtraction) {
            if (toComb1List.get(0) instanceof ValueSpecification) {
              clean = toComb1List.get(0);
              dirty = toComb1List.get(1);
            } else {
              clean = toComb1List.get(1);
              dirty = toComb1List.get(0);
              cleanPartOfInner = 1;
            }
            if (cleanPartOfInner == 0) {
              extraClean = new Addition<Double>(toCombine2, clean);
              extraClean = combine(null, 0, extraClean);
              finalAdd = new Subtraction<Double>(extraClean, dirty);
            } else {
              extraClean = new Subtraction<Double>(toCombine2, clean);
              extraClean = combine(null, 0, extraClean);
              finalAdd = new Addition<Double>(dirty, extraClean);
            }
            return finalAdd;
          } else if (toCombine1 instanceof ColumnReference)
            return expr1;
        } else if (expr1 instanceof Subtraction) {
          ValueExpression finalSub;
          if (toCombine1 instanceof Addition) {
            if (toComb1List.get(0) instanceof ValueSpecification) {
              clean = toComb1List.get(0);
              dirty = toComb1List.get(1);
            } else {
              clean = toComb1List.get(1);
              dirty = toComb1List.get(0);
              cleanPartOfInner = 1;
            }

            ValueExpression extraClean = new Subtraction<Double>(clean, toCombine2);
            extraClean = combine(null, 0, extraClean);
            finalSub = new Addition<Double>(dirty, extraClean);
            return finalSub;
          } else if (toCombine1 instanceof Subtraction) {
            if (toComb1List.get(0) instanceof ValueSpecification) {
              clean = toComb1List.get(0);
              dirty = toComb1List.get(1);
            } else {
              clean = toComb1List.get(1);
              dirty = toComb1List.get(0);
              cleanPartOfInner = 1;
            }

            if (cleanPartOfInner == 0) {
              ValueExpression extraClean = new Subtraction<Double>(clean, toCombine2);
              extraClean = combine(null, 0, extraClean);
              finalSub = new Subtraction<Double>(extraClean, dirty);
            } else {
              ValueExpression extraClean = new Subtraction<Double>(toCombine2, clean);
              extraClean = combine(null, 0, extraClean);
              finalSub = new Subtraction<Double>(dirty, extraClean);
            }
            return finalSub;
          } else if (toCombine1 instanceof Multiplication) {
            if (toComb1List.get(0) instanceof ValueSpecification) {
              clean = toComb1List.get(0);
              dirty = toComb1List.get(1);
            } else {
              clean = toComb1List.get(1);
              dirty = toComb1List.get(0);
              cleanPartOfInner = 1;
            }
            ValueExpression extraClean = new Multiplication<Double>(toCombine2, clean);
            extraClean = combine(null, 0, extraClean);

            finalSub = new Multiplication<Double>(extraClean, dirty);
            return finalSub;
          } else if (toCombine1 instanceof ColumnReference)
View Full Code Here

    toAnalyse = getSameForDouble(toAnalyse);

    compToAnalyse = (ComparisonPredicate) toAnalyse;
    followUps = compToAnalyse.getExpressions();

    ValueExpression leftPart = null;
    try {
      leftPart = combine(null, 0, followUps.get(0));
    } catch (final Exception e) {
      return toAnalyse;
    }

    ValueExpression rightPart = null;
    try {
      rightPart = combine(null, 0, followUps.get(1));
    } catch (final Exception e) {
      return toAnalyse;
    }

    boolean temp = false;
    getInfo(leftPart, temp, 0);
    temp = false;
    getInfo(rightPart, temp, 1);

    if (Parameter[0] == null)
      Parameter[0] = new ValueSpecification<Double>(numConv, 1.0);
    if (Parameter[1] == null)
      Parameter[1] = new ValueSpecification<Double>(numConv, 1.0);

    Parameter[0].inverseNumber();
    ValueExpression fullClean = null;
    if (CleanPart[0] != null) {
      if (CleanPart[1] != null)
        fullClean = new Subtraction<Double>(CleanPart[1], CleanPart[0]);
      else if (CleanPart[1] == null) {
        final ValueExpression temp1 = new ValueSpecification<Double>(numConv, 0.0);
        fullClean = new Subtraction<Double>(temp1, CleanPart[0]);
      }
    } else if (CleanPart[0] == null)
      if (CleanPart[1] != null)
        fullClean = CleanPart[1];
      else
        fullClean = new ValueSpecification(numConv, 0.0);

    fullClean = combine(null, 0, fullClean);
    ValueExpression finalA = new Multiplication<Double>(Parameter[0], Parameter[1]);
    finalA = combine(null, 0, finalA);
    ValueExpression finalB = new Multiplication<Double>(Parameter[0], fullClean);
    finalB = combine(null, 0, finalB);

    final ValueExpression withVariable = new Multiplication<Double>(finalA, Variable[1]);
    final ValueExpression finalRightPart = new Addition<Double>(withVariable, finalB);

    Predicate finalPred;
    if (Parameter[0].isNegative())
      finalPred = new ComparisonPredicate(compToAnalyse.getOperator(true), Variable[0],
          finalRightPart);
View Full Code Here

  Predicate getSameForDouble(Predicate pred) {
    final ComparisonPredicate compPred = (ComparisonPredicate) pred;

    final List<ValueExpression> followUps = compPred.getExpressions();

    final ValueExpression left = changeToDouble(followUps.get(0));
    final ValueExpression right = changeToDouble(followUps.get(1));

    final Predicate finalPred = new ComparisonPredicate<Double>(compPred.getOperator(false),
        left, right);
    return finalPred;
  }
View Full Code Here

TOP

Related Classes of plan_runner.expressions.ValueExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.