use of org.apache.asterix.om.pointables.nonvisitor.ARecordPointable in project asterixdb by apache.
the class RecordFieldsUtil method addNestedField.
public void addNestedField(IValueReference recordArg, IAType fieldType, IARecordBuilder fieldRecordBuilder, int level) throws IOException, AsterixException {
ArrayBackedValueStorage fieldAbvs = getTempBuffer();
ArrayBackedValueStorage valueAbvs = getTempBuffer();
// Name
fieldAbvs.reset();
stringSerde.serialize(nestedName, fieldAbvs.getDataOutput());
// Value
valueAbvs.reset();
ARecordType newType;
if (fieldType == null) {
newType = openType;
} else {
newType = (ARecordType) fieldType;
}
ARecordPointable recordP = getRecordPointable();
recordP.set(recordArg);
processRecord(recordP, newType, valueAbvs.getDataOutput(), level);
fieldRecordBuilder.addField(fieldAbvs, valueAbvs);
}
use of org.apache.asterix.om.pointables.nonvisitor.ARecordPointable in project asterixdb by apache.
the class GetRecordFieldsEvalFactory method createScalarEvaluator.
@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
return new IScalarEvaluator() {
private final ARecordPointable recordPointable = (ARecordPointable) ARecordPointable.FACTORY.createPointable();
private IPointable inputArg0 = new VoidPointable();
private IScalarEvaluator eval0 = recordEvalFactory.createScalarEvaluator(ctx);
private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
private DataOutput out = resultStorage.getDataOutput();
private RecordFieldsUtil rfu = new RecordFieldsUtil();
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
resultStorage.reset();
eval0.evaluate(tuple, inputArg0);
byte[] data = inputArg0.getByteArray();
int offset = inputArg0.getStartOffset();
int len = inputArg0.getLength();
if (data[offset] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
throw new TypeMismatchException(BuiltinFunctions.GET_RECORD_FIELDS, 0, data[offset], ATypeTag.SERIALIZED_RECORD_TYPE_TAG);
}
recordPointable.set(data, offset, len);
try {
rfu.processRecord(recordPointable, recordType, out, 0);
} catch (IOException e) {
throw new HyracksDataException(e);
} catch (AsterixException e) {
throw new HyracksDataException(e);
}
result.set(resultStorage);
}
};
}
Aggregations