private RESULT visitDefaultBinaryEval(CONTEXT context, BinaryEval binaryEval, Stack<EvalNode> stack) { stack.push(binaryEval); RESULT result = visit(context, binaryEval.getLeftExpr(), stack); visit(context, binaryEval.getRightExpr(), stack); stack.pop(); return result; }
protected EvalNode visitBinaryEval(CONTEXT context, Stack<EvalNode> stack, BinaryEval binaryEval) { stack.push(binaryEval); visit(context, binaryEval.getLeftExpr(), stack); visit(context, binaryEval.getRightExpr(), stack); stack.pop(); return binaryEval; }
protected EvalNode visitBinaryEval(CONTEXT context, Stack<EvalNode> stack, BinaryEval binaryEval) { stack.push(binaryEval); visit(context, binaryEval.getLeftExpr(), stack); visit(context, binaryEval.getRightExpr(), stack); stack.pop(); return binaryEval; }
private RESULT visitDefaultBinaryEval(CONTEXT context, BinaryEval binaryEval, Stack<EvalNode> stack) { stack.push(binaryEval); RESULT result = visit(context, binaryEval.getLeftExpr(), stack); visit(context, binaryEval.getRightExpr(), stack); stack.pop(); return result; }
@Override protected EvalNode visitBinaryEval(Context context, Stack<EvalNode> stack, BinaryEval binaryEval) { stack.push(binaryEval); visit(context, binaryEval.getLeftExpr(), stack); context.sb.append(convertBinOperatorToSQLRepr(binaryEval.getType())).append(" "); visit(context, binaryEval.getRightExpr(), stack); stack.pop(); return binaryEval; }
@Override protected EvalNode visitBinaryEval(Context context, Stack<EvalNode> stack, BinaryEval binaryEval) { stack.push(binaryEval); visit(context, binaryEval.getLeftExpr(), stack); context.sb.append(convertBinOperatorToSQLRepr(binaryEval.getType())).append(" "); visit(context, binaryEval.getRightExpr(), stack); stack.pop(); return binaryEval; }
private static void checkDivisionByZero(VerificationState state, BinaryEval evalNode) { if (evalNode.getRightExpr().getType() == EvalType.CONST) { ConstEval constEval = evalNode.getRightExpr(); if (constEval.getValue().asFloat8() == 0) { state.addVerification(new TajoException(Errors.ResultCode.DIVISION_BY_ZERO, evalNode.toString())); } } }
private static void toConjunctiveNormalFormArrayRecursive(EvalNode node, List<EvalNode> found) { if (node.getType() == EvalType.AND) { toConjunctiveNormalFormArrayRecursive(((BinaryEval)node).getLeftExpr(), found); toConjunctiveNormalFormArrayRecursive(((BinaryEval)node).getRightExpr(), found); } else { found.add(node); } }
private static void toConjunctiveNormalFormArrayRecursive(EvalNode node, List<EvalNode> found) { if (node.getType() == EvalType.AND) { toConjunctiveNormalFormArrayRecursive(((BinaryEval)node).getLeftExpr(), found); toConjunctiveNormalFormArrayRecursive(((BinaryEval)node).getRightExpr(), found); } else { found.add(node); } }
private static void toDisjunctiveNormalFormArrayRecursive(EvalNode node, List<EvalNode> found) { if (node.getType() == EvalType.OR) { toDisjunctiveNormalFormArrayRecursive(((BinaryEval)node).getLeftExpr(), found); toDisjunctiveNormalFormArrayRecursive(((BinaryEval)node).getRightExpr(), found); } else { found.add(node); } }
private static void checkDivisionByZero(VerificationState state, BinaryEval evalNode) { if (evalNode.getRightExpr().getType() == EvalType.CONST) { ConstEval constEval = evalNode.getRightExpr(); if (constEval.getValue().asFloat8() == 0) { state.addVerification(new TajoException(Errors.ResultCode.DIVISION_BY_ZERO, evalNode.toString())); } } }
private static void toDisjunctiveNormalFormArrayRecursive(EvalNode node, List<EvalNode> found) { if (node.getType() == EvalType.OR) { toDisjunctiveNormalFormArrayRecursive(((BinaryEval)node).getLeftExpr(), found); toDisjunctiveNormalFormArrayRecursive(((BinaryEval)node).getRightExpr(), found); } else { found.add(node); } }
@Override public EvalNode visitBinaryEval(Object context, Stack<EvalNode> stack, BinaryEval binaryEval) { stack.push(binaryEval); EvalNode lhs = visit(context, binaryEval.getLeftExpr(), stack); EvalNode rhs = visit(context, binaryEval.getRightExpr(), stack); stack.pop(); if (!binaryEval.getLeftExpr().equals(lhs)) { binaryEval.setLeftExpr(lhs); } if (!binaryEval.getRightExpr().equals(rhs)) { binaryEval.setRightExpr(rhs); } if (lhs.getType() == EvalType.CONST && rhs.getType() == EvalType.CONST) { return new ConstEval(binaryEval.bind(null, null).eval(null)); } return binaryEval; }
/** * * @param evalNode The expression to be checked * @return true if an disjunctive expression, consisting of indexable expressions */ private boolean checkIfDisjunctiveButOneVariable(EvalNode evalNode) { if (evalNode.getType() == EvalType.OR) { BinaryEval orEval = (BinaryEval) evalNode; boolean indexable = checkIfIndexablePredicate(orEval.getLeftExpr()) && checkIfIndexablePredicate(orEval.getRightExpr()); boolean sameVariable = EvalTreeUtil.findUniqueColumns(orEval.getLeftExpr()) .equals(EvalTreeUtil.findUniqueColumns(orEval.getRightExpr())); return indexable && sameVariable; } else { return false; } }
private static int getSwitchIndex(EvalNode predicate) { Preconditions.checkArgument(checkIfSimplePredicate(predicate), "This expression cannot be used for switch table: " + predicate); BinaryEval bin = (BinaryEval) predicate; if (bin.getLeftExpr().getType() == EvalType.CONST) { return bin.getLeftExpr().eval(null).asInt4(); } else { return bin.getRightExpr().eval(null).asInt4(); } } }
private static int getSwitchIndex(EvalNode predicate) { Preconditions.checkArgument(checkIfSimplePredicate(predicate), "This expression cannot be used for switch table: " + predicate); BinaryEval bin = (BinaryEval) predicate; if (bin.getLeftExpr().getType() == EvalType.CONST) { return bin.getLeftExpr().eval(null).asInt4(); } else { return bin.getRightExpr().eval(null).asInt4(); } } }
/** * It checks both expressions in a comparison operator are compatible to each other. */ private static void verifyComparisonOperator(VerificationState state, BinaryEval expr) { if (!isCompatibleType(expr.getLeftExpr().getValueType(), expr.getRightExpr().getValueType())) { state.addVerification(new UndefinedOperatorException(expr.toString())); } }
/** * It checks both expressions in a comparison operator are compatible to each other. */ private static void verifyComparisonOperator(VerificationState state, BinaryEval expr) { DataType leftType = expr.getLeftExpr().getValueType(); DataType rightType = expr.getRightExpr().getValueType(); if (!isCompatibleType(leftType, rightType)) { state.addVerification(new UndefinedOperatorException(expr.toString())); } }
@Override protected EvalNode visitBinaryEval(Object context, Stack<EvalNode> stack, BinaryEval binaryEval) { stack.push(binaryEval); EvalNode child = binaryEval.getLeftExpr(); visit(context, child, stack); if (child.getType() == EvalType.AND || child.getType() == EvalType.OR) { binaryEval.setLeftExpr(rewrite((BinaryEval) child)); } child = binaryEval.getRightExpr(); visit(context, child, stack); if (child.getType() == EvalType.AND || child.getType() == EvalType.OR) { binaryEval.setRightExpr(rewrite((BinaryEval) child)); } EvalNode result = rewrite(binaryEval); stack.pop(); return result; }
@Override protected EvalNode visitBinaryEval(Object context, Stack<EvalNode> stack, BinaryEval binaryEval) { stack.push(binaryEval); EvalNode child = binaryEval.getLeftExpr(); visit(context, child, stack); if (child.getType() == EvalType.AND || child.getType() == EvalType.OR) { binaryEval.setLeftExpr(rewrite((BinaryEval) child)); } child = binaryEval.getRightExpr(); visit(context, child, stack); if (child.getType() == EvalType.AND || child.getType() == EvalType.OR) { binaryEval.setRightExpr(rewrite((BinaryEval) child)); } EvalNode result = rewrite(binaryEval); stack.pop(); return result; }