public static boolean isBinaryOperator(EvalType type) { boolean match = false; match |= isArithmeticOperator(type); match |= isLogicalOperator(type) && type != NOT; match |= isComparisonOperator(type) && type != BETWEEN; match |= type == CONCATENATE; match |= type == IN; match |= type == LIKE; match |= type == REGEX; match |= type == SIMILAR_TO; return match; }
public static boolean isBinaryOperator(EvalType type) { boolean match = false; match |= isArithmeticOperator(type); match |= isLogicalOperator(type) && type != NOT; match |= isComparisonOperator(type) && type != BETWEEN; match |= type == CONCATENATE; match |= type == IN; match |= type == LIKE; match |= type == REGEX; match |= type == SIMILAR_TO; return match; }
/** * Split the left term and transform it into the right deep expression. * * @param binary - to be splited * @return the separated expression changed into the right deep expression. * For example, the expr 'x * y' is transformed into '* y'. * * @throws CloneNotSupportedException */ public static PartialBinaryExpr splitRightTerm(BinaryEval binary) { if (!(EvalType.isArithmeticOperator(binary.getType()))) { throw new AlgebraicException("Invalid algebraic operation: " + binary); } if (binary.getRightExpr() instanceof BinaryEval) { return splitRightTerm((BinaryEval) binary.getRightExpr()); } PartialBinaryExpr splitted = new PartialBinaryExpr(binary.getType(), null, binary.getRightExpr()); binary.setRightExpr(null); return splitted; }
/** * Split the left term and transform it into the right deep expression. * * @param binary - to be splited * @return the separated expression changed into the right deep expression. * For example, the expr 'x * y' is transformed into '* y'. * * @throws CloneNotSupportedException */ public static PartialBinaryExpr splitRightTerm(BinaryEval binary) { if (!(EvalType.isArithmeticOperator(binary.getType()))) { throw new AlgebraicException("Invalid algebraic operation: " + binary); } if (binary.getRightExpr() instanceof BinaryEval) { return splitRightTerm((BinaryEval) binary.getRightExpr()); } PartialBinaryExpr splitted = new PartialBinaryExpr(binary.getType(), null, binary.getRightExpr()); binary.setRightExpr(null); return splitted; }
/** * Split the left term and transform it into the right deep expression. * * @param binary - notice the left term of this expr will be eliminated * after done. * @return the separated expression changed into the right deep expression. * For example, the expr 'x * y' is transformed into '* x'. * */ public static PartialBinaryExpr splitLeftTerm(BinaryEval binary) { if (!(EvalType.isArithmeticOperator(binary.getType()))) { throw new AlgebraicException("Invalid algebraic operation: " + binary); } if (binary.getLeftExpr() instanceof BinaryEval) { return splitLeftTerm((BinaryEval) binary.getLeftExpr()); } PartialBinaryExpr splitted = new PartialBinaryExpr(binary.getType(), null, binary.getLeftExpr()); binary.setLeftExpr(null); return splitted; }
/** * Split the left term and transform it into the right deep expression. * * @param binary - notice the left term of this expr will be eliminated * after done. * @return the separated expression changed into the right deep expression. * For example, the expr 'x * y' is transformed into '* x'. * */ public static PartialBinaryExpr splitLeftTerm(BinaryEval binary) { if (!(EvalType.isArithmeticOperator(binary.getType()))) { throw new AlgebraicException("Invalid algebraic operation: " + binary); } if (binary.getLeftExpr() instanceof BinaryEval) { return splitLeftTerm((BinaryEval) binary.getLeftExpr()); } PartialBinaryExpr splitted = new PartialBinaryExpr(binary.getType(), null, binary.getLeftExpr()); binary.setLeftExpr(null); return splitted; }
public EvalNode visitBinaryEval(EvalCodeGenContext context, Stack<EvalNode> stack, BinaryEval binaryEval) { if (EvalType.isLogicalOperator(binaryEval.getType())) { return visitAndOrEval(context, binaryEval, stack); } else if (EvalType.isArithmeticOperator(binaryEval.getType())) { return visitArithmeticEval(context, binaryEval, stack); } else if (EvalType.isComparisonOperator(binaryEval.getType())) { return visitComparisonEval(context, binaryEval, stack); } else if (binaryEval.getType() == EvalType.CONCATENATE) { return visitStringConcat(context, binaryEval, stack); } else if (binaryEval.getType() == EvalType.LIKE || binaryEval.getType() == EvalType.SIMILAR_TO || binaryEval.getType() == EvalType.REGEX) { return visitStringPatternMatch(context, binaryEval, stack); } else if (binaryEval.getType() == EvalType.IN) { return visitInPredicate(context, binaryEval, stack); } else { stack.push(binaryEval); visit(context, binaryEval.getLeftExpr(), stack); visit(context, binaryEval.getRightExpr(), stack); stack.pop(); return binaryEval; } }
public EvalNode visitBinaryEval(EvalCodeGenContext context, Stack<EvalNode> stack, BinaryEval binaryEval) { if (EvalType.isLogicalOperator(binaryEval.getType())) { return visitAndOrEval(context, binaryEval, stack); } else if (EvalType.isArithmeticOperator(binaryEval.getType())) { return visitArithmeticEval(context, binaryEval, stack); } else if (EvalType.isComparisonOperator(binaryEval.getType())) { return visitComparisonEval(context, binaryEval, stack); } else if (binaryEval.getType() == EvalType.CONCATENATE) { return visitStringConcat(context, binaryEval, stack); } else if (binaryEval.getType() == EvalType.LIKE || binaryEval.getType() == EvalType.SIMILAR_TO || binaryEval.getType() == EvalType.REGEX) { return visitStringPatternMatch(context, binaryEval, stack); } else if (binaryEval.getType() == EvalType.IN) { return visitInPredicate(context, binaryEval, stack); } else { stack.push(binaryEval); visit(context, binaryEval.getLeftExpr(), stack); visit(context, binaryEval.getRightExpr(), stack); stack.pop(); return binaryEval; } }
EvalNode rTerm = null; if (EvalType.isArithmeticOperator(left.getType())) { // we can ensure that left is binary.
EvalNode rTerm = null; if (EvalType.isArithmeticOperator(left.getType())) { // we can ensure that left is binary.