예제 #1
0
        /// <summary>
        /// Requests a page, either buffering it or pulling it from the in memory page store
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public Page RequestPage(PageUID ID)
        {
            // Check the Page ID //
            if (ID.PageID < 0)
            {
                throw new Exception(string.Format("Page ID {0} is invalid", ID.PageID));
            }

            this._Host.DebugPrint("TableStore.RequestPage({0})", ID.ToString()); // #DEBUG#

            // Check if the page is in memory //
            if (this.PageIsInMemory(ID))
            {
                this._Host.DebugPrint("TableStore.RequestPage->page found in memory({0})", ID.ToString()); // #DEBUG#
                return(this._PageStore[ID]);
            }

            // Check if the table is in memory or not //
            if (!this.TableIsInMemory(ID.Key))
            {
                throw new ObjectNotInMemoryException(string.Format("Table '{0}' is not memory; critical code error", ID.Key));
            }

            // Otherwise, check if we have space //
            int Size = this._TableStore[ID.Key].PageSize;

            if (!this.HasSpaceFor(Size))
            {
                this.FreeSpace(Size);
            }

            // Tag in the recycling bin //
            this._PageBurnStack.EnqueueOrTag(ID);

            this._Host.DebugPrint("TableStore.RequestPage->page added to burn Intermediary({0})", ID.ToString()); // #DEBUG#

            // Page //
            Page p = TableStore.Buffer(ID.Key, ID.PageID, Size);

            this._PageInMemoryCounts[ID.Key]++;

            this._Host.DebugPrint("TableStore.RequestPage->page buffered({0})", ID.ToString()); // #DEBUG#

            this.PushPage(ID.Key, p);

            return(p);
        }
예제 #2
0
 public TableRef(Host Host, string Path)
 {
     this._Host    = Host;
     this._Key     = Path;
     this._Columns = TableStore.Buffer(Path).Columns;
 }