public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
if (!super.evaluate(tuple, ptr)) {
return false;
}
if (isConstantExpression()) {
PDataType type = getDataType();
Object constantValue = ((LiteralExpression)children.get(0)).getValue();
if (type == PDataType.DECIMAL) {
BigDecimal value = ((BigDecimal)constantValue).multiply((BigDecimal)PDataType.DECIMAL.toObject(ptr, PDataType.LONG));
ptr.set(PDataType.DECIMAL.toBytes(value));
} else {
long constantLongValue = ((Number)constantValue).longValue();
long value = constantLongValue * type.getCodec().decodeLong(ptr, null);
ptr.set(new byte[type.getByteSize()]);
type.getCodec().encodeLong(value, ptr);
}
}
return true;
}