use of org.apache.asterix.om.base.AMutableInt64 in project asterixdb by apache.
the class MonthsFromYearMonthDurationDescriptor method createEvaluatorFactory.
@Override
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
return new IScalarEvaluatorFactory() {
private static final long serialVersionUID = 1L;
@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
return new IScalarEvaluator() {
private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
private DataOutput out = resultStorage.getDataOutput();
private IPointable argPtr0 = new VoidPointable();
private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
@SuppressWarnings("unchecked")
private ISerializerDeserializer<AInt64> int64Serde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT64);
AMutableInt64 aInt64 = new AMutableInt64(0);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
resultStorage.reset();
;
eval0.evaluate(tuple, argPtr0);
byte[] bytes = argPtr0.getByteArray();
int offset = argPtr0.getStartOffset();
if (bytes[offset] != ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG) {
throw new TypeMismatchException(getIdentifier(), 0, bytes[offset], ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG);
}
aInt64.setValue(AYearMonthDurationSerializerDeserializer.getYearMonth(bytes, offset + 1));
int64Serde.serialize(aInt64, out);
result.set(resultStorage);
}
};
}
};
}
Aggregations