private static final int DEC_INDEX = 1;
@Override
protected void doEvaluate(TExecutionContext context, LazyList<? extends ValueSource> inputs, ValueTarget output) {
TClass cached = (TClass) context.objectAt(RET_TYPE_INDEX);
BigDecimalWrapper result = TBigDecimal.getWrapper(context, DEC_INDEX);
result.set(TBigDecimal.getWrapper(inputs.get(0), context.inputTypeAt(0)));
result = roundType.evaluate(result);
TClass outT = context.outputType().typeClass();
if (cached != null && cached != outT)
throw new AssertionError(String.format("Mismatched type! cached: [%s] != output: [%s]",
cached,
outT));
else if (outT == MNumeric.DECIMAL)
output.putObject(result);
else if (outT == MNumeric.BIGINT)
output.putInt64(result.asBigDecimal().longValue());
else if (outT == MNumeric.INT) // INT
output.putInt32(result.asBigDecimal().intValue());
else
throw new AssertionError("Unexpected output type: " + outT);
}
@Override