Example #1
0
        private bool TryOverwriteOverflowPages(TreeNodeHeader *updatedNode, int len, out byte *pos)
        {
            if (updatedNode->Flags == TreeNodeFlags.PageRef)
            {
                var readOnlyOverflowPage = GetReadOnlyTreePage(updatedNode->PageNumber);

                if (len <= readOnlyOverflowPage.OverflowSize)
                {
                    var availableOverflows = _llt.DataPager.GetNumberOfOverflowPages(readOnlyOverflowPage.OverflowSize);

                    var requestedOverflows = _llt.DataPager.GetNumberOfOverflowPages(len);

                    var overflowsToFree = availableOverflows - requestedOverflows;

                    for (int i = 0; i < overflowsToFree; i++)
                    {
                        _llt.FreePage(readOnlyOverflowPage.PageNumber + requestedOverflows + i);
                    }

                    State.RecordFreedPage(readOnlyOverflowPage, overflowsToFree);

                    var writtableOverflowPage = AllocateNewPage(_llt, TreePageFlags.Value, requestedOverflows, updatedNode->PageNumber);

                    writtableOverflowPage.Flags        = PageFlags.Overflow | PageFlags.VariableSizeTreePage;
                    writtableOverflowPage.OverflowSize = len;
                    pos = writtableOverflowPage.Base + Constants.Tree.PageHeaderSize;

                    PageModified?.Invoke(writtableOverflowPage.PageNumber);

                    return(true);
                }
            }
            pos = null;
            return(false);
        }
Example #2
0
        internal TreePage NewPage(TreePageFlags flags, int num)
        {
            var page = AllocateNewPage(_llt, flags, num);

            State.RecordNewPage(page, num);

            PageModified?.Invoke(page.PageNumber);

            return(page);
        }
Example #3
0
        public TreePage ModifyPage(long pageNumber)
        {
            var newPage = _llt.ModifyPage(pageNumber).ToTreePage();

            newPage.Dirty = true;
            _recentlyFoundPages.Reset(pageNumber);

            PageModified?.Invoke(pageNumber);

            return(newPage);
        }
Example #4
0
        internal TreePage NewPage(TreePageFlags flags, long nearbyPage)
        {
            var newPage = _newPageAllocator?.AllocateSinglePage(nearbyPage) ?? _llt.AllocatePage(1);

            var page = PrepareTreePage(flags, 1, newPage);

            State.RecordNewPage(page, 1);

            PageModified?.Invoke(page.PageNumber, page.Flags);

            return(page);
        }
Example #5
0
        private long WriteToOverflowPages(int overflowSize, out byte *dataPos)
        {
            var numberOfPages     = _llt.DataPager.GetNumberOfOverflowPages(overflowSize);
            var overflowPageStart = AllocateNewPage(_llt, TreePageFlags.Value, numberOfPages);

            overflowPageStart.Flags        = PageFlags.Overflow | PageFlags.VariableSizeTreePage;
            overflowPageStart.OverflowSize = overflowSize;
            dataPos = overflowPageStart.Base + Constants.TreePageHeaderSize;

            State.RecordNewPage(overflowPageStart, numberOfPages);

            PageModified?.Invoke(overflowPageStart.PageNumber);

            return(overflowPageStart.PageNumber);
        }
Example #6
0
        public TreePage ModifyPage(long pageNumber)
        {
            var newPage = GetWriteableTreePage(pageNumber);

            newPage.Dirty = true;
            _recentlyFoundPages.Reset(pageNumber);

            if (IsLeafCompressionSupported && newPage.IsCompressed)
            {
                DecompressionsCache.Invalidate(pageNumber, DecompressionUsage.Read);
            }

            PageModified?.Invoke(pageNumber);

            return(newPage);
        }
Example #7
0
        private long WriteToOverflowPages(int overflowSize, out byte *dataPos)
        {
            var numberOfPages = VirtualPagerLegacyExtensions.GetNumberOfOverflowPages(overflowSize);
            var newPage       = _llt.AllocatePage(numberOfPages);

            TreePage overflowPageStart = PrepareTreePage(TreePageFlags.Value, numberOfPages, newPage);

            overflowPageStart.Flags        = PageFlags.Overflow | PageFlags.VariableSizeTreePage;
            overflowPageStart.OverflowSize = overflowSize;
            dataPos = overflowPageStart.Base + Constants.Tree.PageHeaderSize;

            State.RecordNewPage(overflowPageStart, numberOfPages);

            PageModified?.Invoke(overflowPageStart.PageNumber, overflowPageStart.Flags);

            return(overflowPageStart.PageNumber);
        }