Ejemplo n.º 1
0
        private IndexTablePage QueueExtractFirst()
        {
            if (this.m_queueFirstPage == null)
            {
                return(null);
            }
            IndexTablePage queueFirstPage = this.m_queueFirstPage;

            this.m_queueFirstPage   = queueFirstPage.NextPage;
            queueFirstPage.NextPage = null;
            if (this.m_queueFirstPage == null)
            {
                this.m_queueLastPage = null;
            }
            else
            {
                this.m_queueFirstPage.PreviousPage = null;
            }
            return(queueFirstPage);
        }
Ejemplo n.º 2
0
        private IndexTablePage GetPage(long id)
        {
            int            num            = this.CalcPageNum(id);
            IndexTablePage indexTablePage = null;

            if (!this.m_pageCache.TryGetValue(num, out indexTablePage))
            {
                if (this.m_pageCache.Count == this.m_cacheSize)
                {
                    if (this.m_stream == null)
                    {
                        this.m_stream        = this.m_streamCreator.OpenStream();
                        this.m_streamCreator = null;
                        if (!this.m_stream.CanSeek || !this.m_stream.CanRead || !this.m_stream.CanWrite)
                        {
                            Global.Tracer.Assert(false, "Must be able to Seek, Read, and Write stream");
                        }
                    }
                    indexTablePage = this.QueueExtractFirst();
                    int pageNumber = indexTablePage.PageNumber;
                    this.m_pageCache.Remove(pageNumber);
                    if (indexTablePage.Dirty)
                    {
                        long offset = this.CalcPageOffset(pageNumber);
                        this.m_stream.Seek(offset, SeekOrigin.Begin);
                        indexTablePage.Write(this.m_stream);
                    }
                    long offset2 = this.CalcPageOffset(num);
                    this.m_stream.Seek(offset2, SeekOrigin.Begin);
                    indexTablePage.Read(this.m_stream);
                }
                else
                {
                    indexTablePage = new IndexTablePage(this.m_pageSize);
                }
                indexTablePage.PageNumber = num;
                this.m_pageCache[num]     = indexTablePage;
                this.QueueAppendPage(indexTablePage);
            }
            return(indexTablePage);
        }
Ejemplo n.º 3
0
        public long Retrieve(ReferenceID id)
        {
            IndexTablePage page = this.GetPage(id.Value);

            return(this.ReadValue(id.Value, page));
        }
Ejemplo n.º 4
0
        public void Update(ReferenceID id, long value)
        {
            IndexTablePage page = this.GetPage(id.Value);

            this.WriteValue(id.Value, page, value);
        }