public override void Read(Vault vault, BinaryReader br)
        {
            var mKey          = br.ReadUInt64();
            var mClass        = br.ReadUInt64();
            var mParent       = br.ReadUInt64();
            var mTableReserve = br.ReadUInt32();

            br.ReadUInt32();
            var mNumEntries = br.ReadUInt32();
            var mNumTypes   = br.ReadUInt16();
            var mTypesLen   = br.ReadUInt16();

            _layoutPointer = br.ReadPointer();
            br.ReadUInt32();

            Debug.Assert(mTableReserve == mNumEntries);

            Collection = new VltCollection(vault, vault.Database.FindClass(HashManager.ResolveVLT(mClass)), HashManager.ResolveVLT(mKey));

            Debug.Assert(mTypesLen >= mNumTypes);

            _types = new ulong[mNumTypes];
            for (var i = 0; i < mNumTypes; i++)
            {
                _types[i] = (br.ReadUInt64());
            }

            for (var i = 0; i < mTypesLen - mNumTypes; i++)
            {
                br.ReadUInt64();
            }

            _entries = new List <AttribEntry64>();

            for (var i = 0; i < mNumEntries; i++)
            {
                var attribEntry = new AttribEntry64(Collection);

                attribEntry.Read(vault, br);

                // save pos
                long pos      = br.BaseStream.Position;
                var  readData = attribEntry.ReadData(vault, br);
                br.BaseStream.Position = pos;

                if (!readData)
                {
                    continue;
                }

                _entries.Add(attribEntry);
            }

            // TODO: ParentKey
            //Collection.ParentKey = mParent;
            vault.Database.RowManager.AddCollection(Collection);
        }
        public override void Prepare(Vault vault)
        {
            List <KeyValuePair <string, VLTBaseType> > optionalDataColumns = (from pair in Collection.GetData()
                                                                              let field = Collection.Class[pair.Key]
                                                                                          where !field.IsInLayout
                                                                                          orderby field.Name
                                                                                          select pair).ToList();

            _entries = new List <AttribEntry64>();
            _types   = Collection.Class.BaseFields.Select(f => f.TypeName)
                       .Concat(optionalDataColumns.Select(c => Collection.Class[c.Key].TypeName))
                       .Select(s => VLT64Hasher.Hash(s)).Distinct().ToArray();

            for (var index = 0; index < optionalDataColumns.Count; index++)
            {
                var optionalDataColumn = optionalDataColumns[index];
                var entry         = new AttribEntry64(Collection);
                var vltClassField = Collection.Class[optionalDataColumn.Key];

                entry.Key       = VLT64Hasher.Hash(optionalDataColumn.Key);
                entry.TypeIndex = (ushort)Array.IndexOf(_types,
                                                        VLT64Hasher.Hash(vltClassField.TypeName));
                entry.EntryFlags = 0;
                entry.NodeFlags  = NodeFlagsEnum.Default;

                if (entry.IsInline())
                {
                    entry.InlineData = optionalDataColumn.Value;
                    entry.NodeFlags |= NodeFlagsEnum.IsInline;
                }
                else
                {
                    entry.InlineData =
                        new VLTAttribType(Collection.Class, vltClassField, Collection)
                    {
                        Data = optionalDataColumn.Value
                    };
                }

                if (vltClassField.IsArray)
                {
                    entry.NodeFlags |= NodeFlagsEnum.IsArray;
                }

                if ((vltClassField.Flags & DefinitionFlags.HasHandler) != 0)
                {
                    entry.NodeFlags |= NodeFlagsEnum.HasHandler;
                }

                _entries.Add(entry);
            }
        }