Exemple #1
0
        public override void Deserialize(ref SerializationReader mySerializationReader)
        {
            UInt32 _Capacity;

            if (mySerializationReader != null)
            {
                try
                {
                    _UUID = new TypeUUID(this.ObjectUUID.GetByteArray());
                    ParentTypeUUID = new TypeUUID();
                    ParentTypeUUID.Deserialize(ref mySerializationReader);
                    _IsUserDefined = mySerializationReader.ReadBoolean();
                    _IsAbstract = mySerializationReader.ReadBoolean();
                    _Comment = mySerializationReader.ReadString();

                    _Capacity = mySerializationReader.ReadUInt32();

                    _Attributes = new Dictionary<AttributeUUID, TypeAttribute>();

                    _TypeAttributeLookupTable = new Dictionary<AttributeUUID, TypeAttribute>();

                    for (UInt32 i = 0; i < _Capacity; i++)
                    {
                        var _AttrAtrib = new AttributeUUID();
                        _AttrAtrib.Deserialize(ref mySerializationReader);
                        var _TypeObj = new TypeAttribute();
                        _TypeObj.Deserialize(ref mySerializationReader);
                        _Attributes.Add(_AttrAtrib, _TypeObj);
                        _TypeAttributeLookupTable.Add(_AttrAtrib, _TypeObj);
                    }

                    _Capacity = mySerializationReader.ReadUInt32();
                    _TypeSettings = new Dictionary<String, ADBSettingsBase>();

                    for (var i = 0; i < _Capacity; i++)
                    {
                        ADBSettingsBase _ADBSettingsBase = (ADBSettingsBase) mySerializationReader.ReadObject();
                        if(_ADBSettingsBase != null)
                            _TypeSettings.Add(_ADBSettingsBase.Name, _ADBSettingsBase);
                    }

                    _Capacity = mySerializationReader.ReadUInt32();
                    _UniqueAttributes = new List<AttributeUUID>();
                    AttributeUUID AttribID = null;

                    for (UInt32 i = 0; i < _Capacity; i++)
                    {
                        AttribID = new AttributeUUID(ref mySerializationReader);
                        _UniqueAttributes.Add(AttribID);
                    }

                    _Capacity = mySerializationReader.ReadUInt32();
                    _MandatoryAttributes = new HashSet<AttributeUUID>();

                    for (UInt32 i = 0; i < _Capacity; i++)
                    {
                        AttribID = new AttributeUUID(ref mySerializationReader);
                        _MandatoryAttributes.Add(AttribID);
                    }

                    #region Indices

                    _AttributeIndices = new Dictionary<IndexKeyDefinition, Dictionary<String, AAttributeIndex>>();
                    _AttributeIndicesNameLookup = new Dictionary<String, IndexKeyDefinition>();
                    _AttributeIndexLocations = new Dictionary<IndexKeyDefinition, Dictionary<string, Tuple<string, ObjectLocation>>>();

                    var idxCount = mySerializationReader.ReadUInt32();
                    for (var i = 0; i < idxCount; i++)
                    {

                        var idxKey = new IndexKeyDefinition();
                        idxKey.Deserialize(ref mySerializationReader);

                        //_AttributeIndices.Add(idxKey, new Dictionary<String, AttributeIndex>());

                        var idxVersionCount = mySerializationReader.ReadUInt32();

                        _AttributeIndexLocations.Add(idxKey, new Dictionary<string, Tuple<string, ObjectLocation>>());
                        for (var j = 0; j < idxVersionCount; j++)
                        {

                            var key                 = mySerializationReader.ReadString();
                            var idxLocation         = mySerializationReader.ReadString();
                            var indexType           = mySerializationReader.ReadString();

                            _AttributeIndexLocations[idxKey][key] = new Tuple<string,ObjectLocation>(indexType, new ObjectLocation(idxLocation));

                            //idx.IndexKeyDefinition  = idxKey;
                            //AddAttributeIndex(idx as AAttributeIndex);

                        }

                    }

                    #endregion

                }

                catch (Exception e)
                {
                    throw new SerializationException("The GraphDBType could not be deserialized!\n\n" + e);
                }

            }
        }
Exemple #2
0
        public override void Deserialize(ref SerializationReader mySerializationReader)
        {
            UInt32 _Capacity;

            if (mySerializationReader != null)
            {
                try
                {
                    _UUID = new TypeUUID(this.ObjectUUID.GetByteArray());
                    ParentTypeUUID = new TypeUUID();
                    ParentTypeUUID.Deserialize(ref mySerializationReader);
                    _IsUserDefined = mySerializationReader.ReadBoolean();
                    _IsAbstract = mySerializationReader.ReadBoolean();
                    _Comment = mySerializationReader.ReadString();

                    _Capacity = mySerializationReader.ReadUInt32();

                    _Attributes = new Dictionary<AttributeUUID, TypeAttribute>();

                    _TypeAttributeLookupTable = new Dictionary<AttributeUUID, TypeAttribute>();

                    for (UInt32 i = 0; i < _Capacity; i++)
                    {
                        var _AttrAtrib = new AttributeUUID();
                        _AttrAtrib.Deserialize(ref mySerializationReader);
                        var _TypeObj = new TypeAttribute();
                        _TypeObj.Deserialize(ref mySerializationReader);
                        _Attributes.Add(_AttrAtrib, _TypeObj);
                        _TypeAttributeLookupTable.Add(_AttrAtrib, _TypeObj);
                    }

                    _Capacity = mySerializationReader.ReadUInt32();
                    _TypeSettings = new Dictionary<String, ADBSettingsBase>();

                    for (var i = 0; i < _Capacity; i++)
                    {
                        ADBSettingsBase _ADBSettingsBase = (ADBSettingsBase) mySerializationReader.ReadObject();
                        if(_ADBSettingsBase != null)
                            _TypeSettings.Add(_ADBSettingsBase.Name, _ADBSettingsBase);
                    }

                    _Capacity = mySerializationReader.ReadUInt32();
                    _UniqueAttributes = new List<AttributeUUID>();
                    AttributeUUID AttribID = null;

                    for (UInt32 i = 0; i < _Capacity; i++)
                    {
                        AttribID = new AttributeUUID(ref mySerializationReader);
                        _UniqueAttributes.Add(AttribID);
                    }

                    _Capacity = mySerializationReader.ReadUInt32();
                    _MandatoryAttributes = new HashSet<AttributeUUID>();

                    for (UInt32 i = 0; i < _Capacity; i++)
                    {
                        AttribID = new AttributeUUID(ref mySerializationReader);
                        _MandatoryAttributes.Add(AttribID);
                    }

                    ObjectDirectoryShards = mySerializationReader.ReadUInt16();

                    #region Indices

                    _AttributeIndices = new Dictionary<IndexKeyDefinition, Dictionary<String, AAttributeIndex>>();
                    _AttributeIndicesNameLookup = new Dictionary<String, IndexKeyDefinition>();

                    var idxCount = mySerializationReader.ReadUInt32();
                    for (var i = 0; i < idxCount; i++)
                    {

                        var idxKey = new IndexKeyDefinition();
                        idxKey.Deserialize(ref mySerializationReader);

                        //_AttributeIndices.Add(idxKey, new Dictionary<String, AttributeIndex>());

                        var idxVersionCount = mySerializationReader.ReadUInt32();

                        for (var j = 0; j < idxVersionCount; j++)
                        {

                            var key                 = mySerializationReader.ReadString();
                            var fileSystemLocation  = new ObjectLocation(mySerializationReader.ReadString());
                            var indexEdition        = mySerializationReader.ReadString();
                            var indexName           = mySerializationReader.ReadString();
                            var indexType           = mySerializationReader.ReadString();
                            var isUUIDIdx           = mySerializationReader.ReadBoolean();
                            var keyCount            = mySerializationReader.ReadUInt64();
                            var valueCount          = mySerializationReader.ReadUInt64();
                            var attributeIdxShards = mySerializationReader.ReadUInt16();

                            //var CreateIdxExcept = CreateAttributeIndex(indexName, idxKey.IndexKeyAttributeUUIDs, indexEdition, indexObjectType, fileSystemLocation);

                            if (isUUIDIdx)
                            {
                                AddAttributeIndex(new UUIDIndex(indexName, idxKey, this, attributeIdxShards, indexType, indexEdition, keyCount));
                            }
                            else
                            {
                                AddAttributeIndex(new AttributeIndex(indexName, idxKey, this, attributeIdxShards, indexType, indexEdition, keyCount, valueCount));
                            }

                            //if (CreateIdxExcept.Failed())
                            //    throw new GraphDBException(CreateIdxExcept.Errors);
                        }

                    }

                    #endregion

                }

                catch (Exception e)
                {
                    throw new SerializationException("The GraphDBType could not be deserialized!\n\n" + e);
                }

            }
        }
Exemple #3
0
        public void Deserialize(ref SerializationReader mySerializationReader)
        {
            UInt32 _Capacity;

            try
            {

                if (mySerializationReader != null)
                {

                    UUID = new AttributeUUID();
                    UUID.Deserialize(ref mySerializationReader);
                    DBTypeUUID = new TypeUUID();
                    DBTypeUUID.Deserialize(ref mySerializationReader);
                    KindOfType = (KindsOfType)mySerializationReader.ReadOptimizedByte();
                    TypeCharacteristics = new TypeCharacteristics();
                    TypeCharacteristics.Deserialize(ref mySerializationReader);

                    Name = mySerializationReader.ReadString();

                    var hasEdgeType = mySerializationReader.ReadBoolean();

                    if (hasEdgeType)
                    {
                        try
                        {
                            EdgeType = (IEdgeType) mySerializationReader.ReadObject();
                        }
                        catch(Exception ex)
                        {
                            //NLOG: temporarily commented
                            //Logger.Fatal("Could not deserialize EdgeType");
                            throw new GraphDBException(new Error_UnknownDBError(ex));
                        }

                    }

                    RelatedGraphDBTypeUUID = new TypeUUID();
                    RelatedGraphDBTypeUUID.Deserialize(ref mySerializationReader);

                    if (TypeCharacteristics.IsBackwardEdge)
                        BackwardEdgeDefinition = (EdgeKey) mySerializationReader.ReadObject();

                    DefaultValue = (IObject) mySerializationReader.ReadObject();

                    #region Read Settings

                    _Capacity = mySerializationReader.ReadUInt32();

                    _Settings = new Dictionary<String, ADBSettingsBase>();

                    for (var i = 0; i < _Capacity; i++)
                    {

                        var _SettingObject = (ADBSettingsBase) mySerializationReader.ReadObject();

                        if (_SettingObject != null)
                            _Settings.Add(_SettingObject.Name, _SettingObject);

                        /*Type settingType = (Type)mySerializationReader.ReadObject();
                        ADBSettingsBase _SettingObject = null;
                        try
                        {
                            _SettingObject = (ADBSettingsBase)Activator.CreateInstance(settingType);
                        }
                        catch
                        {
                            Logger.Error("Could not create an instance of setting " + settingType.ToString());
                        }
                        Byte[] Bytes = (Byte[])mySerializationReader.ReadObject();
                        if (_SettingObject != null)
                        {
                            _SettingObject.Deserialize(new SerializationReader(Bytes));
                            _Settings.Add(_SettingObject.Name, _SettingObject);
                        }*/
                    }

                    #endregion

                }
            }

            catch (Exception e)
            {
                throw new SerializationException("The Setting could not be deserialized!\n\n" + e);
            }
        }