Search in sources :

Example 1 with AFlatValuePointable

use of org.apache.asterix.om.pointables.AFlatValuePointable in project asterixdb by apache.

the class JavaFunctionHelper method setArgument.

public void setArgument(int index, IValueReference valueReference) throws IOException, AsterixException {
    IVisitablePointable pointable = null;
    IJObject jObject = null;
    IAType type = finfo.getParamList().get(index);
    switch(type.getTypeTag()) {
        case OBJECT:
            pointable = pointableAllocator.allocateRecordValue(type);
            pointable.set(valueReference);
            jObject = pointableVisitor.visit((ARecordVisitablePointable) pointable, getTypeInfo(index, type));
            break;
        case ARRAY:
        case MULTISET:
            pointable = pointableAllocator.allocateListValue(type);
            pointable.set(valueReference);
            jObject = pointableVisitor.visit((AListVisitablePointable) pointable, getTypeInfo(index, type));
            break;
        case ANY:
            throw new RuntimeDataException(ErrorCode.LIBRARY_JAVA_FUNCTION_HELPER_CANNOT_HANDLE_ARGU_TYPE, type.getTypeTag());
        default:
            pointable = pointableAllocator.allocateFieldValue(type);
            pointable.set(valueReference);
            jObject = pointableVisitor.visit((AFlatValuePointable) pointable, getTypeInfo(index, type));
            break;
    }
    arguments[index] = jObject;
}
Also used : AFlatValuePointable(org.apache.asterix.om.pointables.AFlatValuePointable) ARecordVisitablePointable(org.apache.asterix.om.pointables.ARecordVisitablePointable) AListVisitablePointable(org.apache.asterix.om.pointables.AListVisitablePointable) IVisitablePointable(org.apache.asterix.om.pointables.base.IVisitablePointable) IJObject(org.apache.asterix.external.api.IJObject) IAType(org.apache.asterix.om.types.IAType) RuntimeDataException(org.apache.asterix.common.exceptions.RuntimeDataException)

Aggregations

RuntimeDataException (org.apache.asterix.common.exceptions.RuntimeDataException)1 IJObject (org.apache.asterix.external.api.IJObject)1 AFlatValuePointable (org.apache.asterix.om.pointables.AFlatValuePointable)1 AListVisitablePointable (org.apache.asterix.om.pointables.AListVisitablePointable)1 ARecordVisitablePointable (org.apache.asterix.om.pointables.ARecordVisitablePointable)1 IVisitablePointable (org.apache.asterix.om.pointables.base.IVisitablePointable)1 IAType (org.apache.asterix.om.types.IAType)1