Search in sources :

Example 16 with AOrderedList

use of org.apache.asterix.om.base.AOrderedList in project asterixdb by apache.

the class AOrderedListSerializerDeserializer method deserialize.

@Override
public AOrderedList deserialize(DataInput in) throws HyracksDataException {
    try {
        ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(in.readByte());
        IAType currentItemType = itemType;
        @SuppressWarnings("rawtypes") ISerializerDeserializer currentDeserializer = deserializer;
        if (itemType.getTypeTag() == ATypeTag.ANY && typeTag != ATypeTag.ANY) {
            currentItemType = TypeTagUtil.getBuiltinTypeByTag(typeTag);
            currentDeserializer = SerializerDeserializerProvider.INSTANCE.getNonTaggedSerializerDeserializer(currentItemType);
        }
        List<IAObject> items = new ArrayList<IAObject>();
        // list size
        in.readInt();
        int numberOfitems;
        numberOfitems = in.readInt();
        if (numberOfitems > 0) {
            if (!NonTaggedFormatUtil.isFixedSizedCollection(currentItemType)) {
                for (int i = 0; i < numberOfitems; i++) in.readInt();
            }
            for (int i = 0; i < numberOfitems; i++) {
                IAObject v = (IAObject) currentDeserializer.deserialize(in);
                items.add(v);
            }
        }
        AOrderedListType type = new AOrderedListType(currentItemType, "orderedlist");
        return new AOrderedList(type, items);
    } catch (Exception e) {
        throw new HyracksDataException(e);
    }
}
Also used : AOrderedList(org.apache.asterix.om.base.AOrderedList) ATypeTag(org.apache.asterix.om.types.ATypeTag) IAObject(org.apache.asterix.om.base.IAObject) AOrderedListType(org.apache.asterix.om.types.AOrderedListType) ArrayList(java.util.ArrayList) ISerializerDeserializer(org.apache.hyracks.api.dataflow.value.ISerializerDeserializer) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) AsterixException(org.apache.asterix.common.exceptions.AsterixException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IAType(org.apache.asterix.om.types.IAType)

Aggregations

AOrderedList (org.apache.asterix.om.base.AOrderedList)16 AString (org.apache.asterix.om.base.AString)13 ArrayList (java.util.ArrayList)8 ConstantExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ConstantExpression)8 AsterixConstantValue (org.apache.asterix.om.constants.AsterixConstantValue)7 IAObject (org.apache.asterix.om.base.IAObject)5 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)5 AInt32 (org.apache.asterix.om.base.AInt32)4 ARecord (org.apache.asterix.om.base.ARecord)4 AOrderedListType (org.apache.asterix.om.types.AOrderedListType)4 IAType (org.apache.asterix.om.types.IAType)4 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)4 AbstractFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)4 ScalarFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression)4 List (java.util.List)3 IACursor (org.apache.asterix.om.base.IACursor)3 ARecordType (org.apache.asterix.om.types.ARecordType)3 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)3 VariableReferenceExpression (org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression)3 DataOutput (java.io.DataOutput)2