public EvalNode visitCast(EvalCodeGenContext context, Stack<EvalNode> stack, CastEval cast) { DataType srcType = cast.getOperand().getValueType(); DataType targetType = cast.getValueType(); if (srcType.equals(targetType)) { visit(context, cast.getChild(), stack); return cast; } visit(context, cast.getChild(), stack); Label ifNull = new Label(); Label afterEnd = new Label(); context.emitNullityCheck(ifNull); context.castInsn(srcType, targetType); context.pushNullFlag(true); emitGotoLabel(context, afterEnd); emitLabel(context, ifNull); context.pop(srcType); context.pushDummyValue(targetType); context.pushNullFlag(false); emitLabel(context, afterEnd); return cast; }
@Override public EvalNode visitCastExpr(Context ctx, Stack<Expr> stack, CastExpr expr) throws TajoException { EvalNode child = super.visitCastExpr(ctx, stack, expr); // if it is a casting operation for a constant value, it will be pre-computed and casted to a constant value. if (child.getType() == EvalType.CONST) { ConstEval constEval = (ConstEval) child; // some cast operation may require earlier evaluation with timezone. return new ConstEval( DatumFactory.cast(constEval.getValue(), LogicalPlanner.convertDataType(expr.getTarget()), ctx.timeZone)); } else { return new CastEval(ctx.queryContext, child, LogicalPlanner.convertDataType(expr.getTarget())); } }
@Override public EvalNode visitUnaryEval(EvalTreeProtoBuilderContext context, UnaryEval unary, Stack<EvalNode> stack) { // visiting and registering childs super.visitUnaryEval(context, unary, stack); int [] childIds = registerGetChildIds(context, unary); // building itself PlanProto.UnaryEval.Builder unaryBuilder = PlanProto.UnaryEval.newBuilder(); unaryBuilder.setChildId(childIds[0]); if (unary.getType() == EvalType.IS_NULL) { IsNullEval isNullEval = (IsNullEval) unary; unaryBuilder.setNegative(isNullEval.isNot()); } else if (unary.getType() == EvalType.SIGNED) { SignedEval signedEval = (SignedEval) unary; unaryBuilder.setNegative(signedEval.isNegative()); } else if (unary.getType() == EvalType.CAST) { CastEval castEval = (CastEval) unary; unaryBuilder.setCastingType(castEval.getValueType()); } // registering itself and building EvalNode PlanProto.EvalNode.Builder builder = createEvalBuilder(context, unary); builder.setUnary(unaryBuilder); context.treeBuilder.addNodes(builder); return unary; }
leftColumn = joinQual.getLeftExpr(); } else if (joinQual.getLeftExpr().getType() == EvalType.CAST) { leftColumn = (FieldEval) ((CastEval)joinQual.getLeftExpr()).getOperand();
@Override public EvalNode visitUnaryEval(EvalTreeProtoBuilderContext context, UnaryEval unary, Stack<EvalNode> stack) { // visiting and registering childs super.visitUnaryEval(context, unary, stack); int [] childIds = registerGetChildIds(context, unary); // building itself PlanProto.UnaryEval.Builder unaryBuilder = PlanProto.UnaryEval.newBuilder(); unaryBuilder.setChildId(childIds[0]); if (unary.getType() == EvalType.IS_NULL) { IsNullEval isNullEval = (IsNullEval) unary; unaryBuilder.setNegative(isNullEval.isNot()); } else if (unary.getType() == EvalType.SIGNED) { SignedEval signedEval = (SignedEval) unary; unaryBuilder.setNegative(signedEval.isNegative()); } else if (unary.getType() == EvalType.CAST) { CastEval castEval = (CastEval) unary; unaryBuilder.setCastingType(castEval.getValueType().getProto()); } // registering itself and building EvalNode PlanProto.EvalNode.Builder builder = createEvalBuilder(context, unary); builder.setUnary(unaryBuilder); context.treeBuilder.addNodes(builder); return unary; }
leftColumn = joinQual.getLeftExpr(); } else if (joinQual.getLeftExpr().getType() == EvalType.CAST) { leftColumn = (FieldEval) ((CastEval)joinQual.getLeftExpr()).getOperand();
public EvalNode visitCast(EvalCodeGenContext context, Stack<EvalNode> stack, CastEval cast) { org.apache.tajo.type.Type srcType = cast.getOperand().getValueType(); org.apache.tajo.type.Type targetType = cast.getValueType(); if (srcType.equals(targetType)) { visit(context, cast.getChild(), stack); return cast; } visit(context, cast.getChild(), stack); Label ifNull = new Label(); Label afterEnd = new Label(); context.emitNullityCheck(ifNull); context.castInsn(srcType, targetType); context.pushNullFlag(true); emitGotoLabel(context, afterEnd); emitLabel(context, ifNull); context.pop(srcType); context.pushDummyValue(targetType); context.pushNullFlag(false); emitLabel(context, afterEnd); return cast; }
@Override public EvalNode visitCastExpr(Context ctx, Stack<Expr> stack, CastExpr expr) throws TajoException { EvalNode child = super.visitCastExpr(ctx, stack, expr); // if it is a casting operation for a constant value, it will be pre-computed and casted to a constant value. if (child.getType() == EvalType.CONST) { ConstEval constEval = (ConstEval) child; // some cast operation may require earlier evaluation with timezone. return new ConstEval( DatumFactory.cast(constEval.getValue(), LogicalPlanner.convertDataType(expr.getTarget()).getDataType(), ctx.timeZone)); } else { return new CastEval(ctx.queryContext, child, LogicalPlanner.convertDataType(expr.getTarget()).getDataType()); } }
break; case CAST: current = new CastEval(context, child, unaryProto.getCastingType()); break; case SIGNED:
break; case CAST: current = new CastEval(context, child, TypeProtobufEncoder.decode(unaryProto.getCastingType())); break; case SIGNED:
return new CastEval(ctx.queryContext, evalNode, toType);
return new CastEval(ctx.queryContext, evalNode, toType);