Search in sources :

Example 26 with IAObject

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

the class ARecordSerializerDeserializer method deserialize.

@Override
public ARecord deserialize(DataInput in) throws HyracksDataException {
    try {
        boolean isExpanded = isExpandedRecord(in);
        IAObject[] schemaFields = getValuesForSchemaFields(in);
        if (isExpanded) {
            int numberOfOpenFields = in.readInt();
            String[] fieldNames = new String[numberOfOpenFields];
            IAType[] fieldTypes = new IAType[numberOfOpenFields];
            IAObject[] openFields = new IAObject[numberOfOpenFields];
            for (int i = 0; i < numberOfOpenFields; i++) {
                in.readInt();
                in.readInt();
            }
            for (int i = 0; i < numberOfOpenFields; i++) {
                fieldNames[i] = AStringSerializerDeserializer.INSTANCE.deserialize(in).getStringValue();
                openFields[i] = AObjectSerializerDeserializer.INSTANCE.deserialize(in);
                fieldTypes[i] = openFields[i].getType();
            }
            ARecordType openPartRecType = new ARecordType(null, fieldNames, fieldTypes, true);
            if (numberOfSchemaFields > 0) {
                ARecordType mergedRecordType = mergeRecordTypes(this.recordType, openPartRecType);
                IAObject[] mergedFields = mergeFields(schemaFields, openFields);
                return new ARecord(mergedRecordType, mergedFields);
            } else {
                return new ARecord(openPartRecType, openFields);
            }
        } else {
            return new ARecord(this.recordType, schemaFields);
        }
    } catch (IOException e) {
        throw new HyracksDataException(e);
    }
}
Also used : ARecord(org.apache.asterix.om.base.ARecord) IAObject(org.apache.asterix.om.base.IAObject) AString(org.apache.asterix.om.base.AString) IOException(java.io.IOException) ARecordType(org.apache.asterix.om.types.ARecordType) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IAType(org.apache.asterix.om.types.IAType)

Example 27 with IAObject

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

the class AUnorderedListSerializerDeserializer method deserialize.

@Override
public AUnorderedList deserialize(DataInput in) throws HyracksDataException {
    // TODO: schemaless unordered list deserializer
    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 size
        in.readInt();
        int numberOfitems;
        numberOfitems = in.readInt();
        ArrayList<IAObject> items = new ArrayList<IAObject>();
        if (numberOfitems > 0) {
            if (!NonTaggedFormatUtil.isFixedSizedCollection(currentItemType)) {
                for (int i = 0; i < numberOfitems; i++) in.readInt();
            }
            for (int i = 0; i < numberOfitems; i++) {
                items.add((IAObject) currentDeserializer.deserialize(in));
            }
        }
        AUnorderedListType type = new AUnorderedListType(currentItemType, "unorderedlist");
        return new AUnorderedList(type, items);
    } catch (Exception e) {
        throw new HyracksDataException(e);
    }
}
Also used : ATypeTag(org.apache.asterix.om.types.ATypeTag) IAObject(org.apache.asterix.om.base.IAObject) ArrayList(java.util.ArrayList) AUnorderedList(org.apache.asterix.om.base.AUnorderedList) AUnorderedListType(org.apache.asterix.om.types.AUnorderedListType) 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

IAObject (org.apache.asterix.om.base.IAObject)27 AsterixConstantValue (org.apache.asterix.om.constants.AsterixConstantValue)16 AString (org.apache.asterix.om.base.AString)12 ConstantExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ConstantExpression)10 ATypeTag (org.apache.asterix.om.types.ATypeTag)9 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)8 ArrayList (java.util.ArrayList)7 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)7 AOrderedList (org.apache.asterix.om.base.AOrderedList)5 IAType (org.apache.asterix.om.types.IAType)5 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)5 ScalarFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression)5 AInt32 (org.apache.asterix.om.base.AInt32)4 AbstractFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)4 DataOutput (java.io.DataOutput)3 ARecordType (org.apache.asterix.om.types.ARecordType)3 Mutable (org.apache.commons.lang3.mutable.Mutable)3 ISerializerDeserializer (org.apache.hyracks.api.dataflow.value.ISerializerDeserializer)3 DataInput (java.io.DataInput)2 IOException (java.io.IOException)2