Пример #1
0
        /// <summary>
        /// Given an id obtained by some previous <code>Write</code> and a deserializer, recreates some data.
        /// </summary>
        /// <returns>Deserialized data.</returns>
        public T Read <T>(PageableStoreId id, Func <BuildXLReader, T> deserializer)
        {
            Contract.Requires(id.IsValid);
            Contract.Requires(Contains(id));
            Contract.RequiresNotNull(deserializer);
            ItemLocation itemLocation = m_itemLocations[id.Value];

            return(itemLocation.PageStream.Read <T>(this, itemLocation.Offset, deserializer));
        }
Пример #2
0
        protected static SerializedState ReadSerializedState(BuildXLReader reader)
        {
            Contract.RequiresNotNull(reader);

            bool debug       = reader.ReadBoolean();
            int  streamCount = reader.ReadInt32();

            int[] pageStreamLengths = new int[streamCount];
            for (int i = 0; i < streamCount; i++)
            {
                pageStreamLengths[i] = reader.ReadInt32();
            }

            List <PageStreamBase> streams = new List <PageStreamBase>(streamCount);

            for (int i = 0; i < streamCount; i++)
            {
                streams.Add(MemoryPageStream.Deserialize(reader, pageStreamLengths[i]));
            }

            Contract.Assert(streams.Count == streamCount);
            int lastId = reader.ReadInt32();
            ConcurrentDenseIndex <ItemLocation> offsets = new ConcurrentDenseIndex <ItemLocation>(debug);

            for (uint i = 0; i < lastId; i++)
            {
                PageableStoreId id = new PageableStoreId(i + 1);

                var streamIdentifier = reader.ReadInt32();
                var offset           = reader.ReadInt32();

                offsets[id.Value] = new ItemLocation(streams[streamIdentifier], offset);
            }

            return(new SerializedState()
            {
                Debug = debug,
                PageStreams = streams,
                ItemLocations = offsets,
                LastId = lastId,
            });
        }
Пример #3
0
 public bool Contains(PageableStoreId id)
 {
     Contract.Requires(id.IsValid);
     return(id.Value > 0 && id.Value <= m_lastId);
 }