/** * Convert EvalType the operator notation into SQL notation * * @param op EvalType * @return SQL representation */ public String convertBinOperatorToSQLRepr(EvalType op) { return op.getOperatorName(); } }
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; }
@Override public String getName() { return type.name(); }
@Override public EvalNode deserialize(JsonElement json, Type type, JsonDeserializationContext ctx) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); String nodeName = CommonGsonHelper.getOrDie(jsonObject, "type").getAsString(); Class clazz = EvalType.valueOf(nodeName).getBaseClass(); return ctx.deserialize(jsonObject.get("body"), clazz); }
EvalType type = EvalType.valueOf(protoNode.getType().name()); if (EvalType.isUnaryOperator(type)) { PlanProto.UnaryEval unaryProto = protoNode.getUnary(); EvalNode child = evalNodeMap.get(unaryProto.getChildId()); break; default: throw new RuntimeException("Unknown EvalType: " + type.name()); } else if (EvalType.isBinaryOperator(type)) { PlanProto.BinaryEval binProto = protoNode.getBinary(); EvalNode lhs = evalNodeMap.get(binProto.getLhsId()); evalNodeMap.get(ifCondProto.getThen())); } else if (EvalType.isFunction(type)) { PlanProto.FunctionEval funcProto = protoNode.getFunction(); throw new TajoInternalError("Unknown EvalType: " + type.name());
/** * 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) { super.visitBinaryEval(context, stack, binaryEval); if (EvalType.isStringPatternMatchOperator(binaryEval.getType())) { if (!context.symbols.containsKey(binaryEval)) { String fieldName = binaryEval.getType().name() + "_" + context.seqId++; context.symbols.put(binaryEval, fieldName); Class clazz = EvalCodeGenerator.getStringPatternEvalClass(binaryEval.getType()); context.classWriter.visitField(Opcodes.ACC_PRIVATE, fieldName, "L" + TajoGeneratorAdapter.getInternalName(clazz) + ";", null, null); } } else if (binaryEval.getType() == EvalType.IN) { if (!context.symbols.containsKey(binaryEval)) { String fieldName = binaryEval.getType().name() + "_" + context.seqId++; context.symbols.put(binaryEval, fieldName); context.classWriter.visitField(Opcodes.ACC_PRIVATE, fieldName, "L" + TajoGeneratorAdapter.getInternalName(InEval.class) + ";", null, null); } } return binaryEval; }
boolean joinComparator; if (includeThetaJoin) { joinComparator = EvalType.isComparisonOperator(expr.getType()); } else { joinComparator = expr.getType() == EvalType.EQUAL;
initMethod.visitFieldInsn(Opcodes.PUTFIELD, this.owner, entry.getValue(), getDescription(InEval.class)); } else if (EvalType.isStringPatternMatchOperator(entry.getKey().getType())) { PatternMatchPredicateEval patternPredicate = (PatternMatchPredicateEval) entry.getKey();
/** * It removes all table names from FieldEvals in targets * * @param sourceTargets The targets to be stripped * @return The stripped targets */ public static List<Target> stripTarget(List<Target> sourceTargets) { List<Target> copy = new ArrayList<>(); for (int i = 0; i < sourceTargets.size(); i++) { try { copy.add((Target) sourceTargets.get(i).clone()); } catch (CloneNotSupportedException e) { throw new InternalError(e.getMessage()); } if (copy.get(i).getEvalTree().getType().equals(EvalType.FIELD)) { FieldEval fieldEval = copy.get(i).getEvalTree(); if (fieldEval.getColumnRef().hasQualifier()) { fieldEval.replaceColumnRef(fieldEval.getColumnName()); } } } return copy; }
EvalType type = EvalType.valueOf(protoNode.getType().name()); if (EvalType.isUnaryOperator(type)) { PlanProto.UnaryEval unaryProto = protoNode.getUnary(); EvalNode child = evalNodeMap.get(unaryProto.getChildId()); break; default: throw new RuntimeException("Unknown EvalType: " + type.name()); } else if (EvalType.isBinaryOperator(type)) { PlanProto.BinaryEval binProto = protoNode.getBinary(); EvalNode lhs = evalNodeMap.get(binProto.getLhsId()); evalNodeMap.get(ifCondProto.getThen())); } else if (EvalType.isFunction(type)) { PlanProto.FunctionEval funcProto = protoNode.getFunction(); throw new TajoInternalError("Unknown EvalType: " + type.name());
/** * 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; }
public EvalNode visitBinaryEval(EvalCodeGenContext context, Stack<EvalNode> stack, BinaryEval binaryEval) { super.visitBinaryEval(context, stack, binaryEval); if (EvalType.isStringPatternMatchOperator(binaryEval.getType())) { if (!context.symbols.containsKey(binaryEval)) { String fieldName = binaryEval.getType().name() + "_" + context.seqId++; context.symbols.put(binaryEval, fieldName); Class clazz = EvalCodeGenerator.getStringPatternEvalClass(binaryEval.getType()); context.classWriter.visitField(Opcodes.ACC_PRIVATE, fieldName, "L" + TajoGeneratorAdapter.getInternalName(clazz) + ";", null, null); } } else if (binaryEval.getType() == EvalType.IN) { if (!context.symbols.containsKey(binaryEval)) { String fieldName = binaryEval.getType().name() + "_" + context.seqId++; context.symbols.put(binaryEval, fieldName); context.classWriter.visitField(Opcodes.ACC_PRIVATE, fieldName, "L" + TajoGeneratorAdapter.getInternalName(InEval.class) + ";", null, null); } } return binaryEval; }
@Override public EvalNode deserialize(JsonElement json, Type type, JsonDeserializationContext ctx) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); String nodeName = CommonGsonHelper.getOrDie(jsonObject, "type").getAsString(); Class clazz = EvalType.valueOf(nodeName).getBaseClass(); return ctx.deserialize(jsonObject.get("body"), clazz); }
boolean joinComparator; if (includeThetaJoin) { joinComparator = EvalType.isComparisonOperator(expr.getType()); } else { joinComparator = expr.getType() == EvalType.EQUAL;
initMethod.visitFieldInsn(Opcodes.PUTFIELD, this.owner, entry.getValue(), getDescription(InEval.class)); } else if (EvalType.isStringPatternMatchOperator(entry.getKey().getType())) { PatternMatchPredicateEval patternPredicate = (PatternMatchPredicateEval) entry.getKey();
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; }
@Override public String getName() { return type.name(); }
/** * 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; }
/** * Convert EvalType the operator notation into SQL notation * * @param op EvalType * @return SQL representation */ public String convertBinOperatorToSQLRepr(EvalType op) { return op.getOperatorName(); } }