Exemplo n.º 1
0
        public byte[] GetPageBytes(PagePointer loc, bool putResultToCache = true)
        {
            if (!_backupMode)
            {
                return(_bufferManager.GetPageBytes(loc.FileID, loc.PageID, putResultToCache));
            }

            //var pagesInFile = (int)(bufferManager.GetFileLen(loc.FileID) / 8192);

            //var pages = Enumerable.Range(0, pagesInFile).Select(x => new PagePointer(loc.FileID, x)).ToArray();

            //var result = ( from pagePointer in pages
            //               let pageHeaderBytes = bufferManager.GetHeaderBytes(pagePointer.FileID, pagePointer.PageID)
            //               let pageHeader = new PageHeader(pageHeaderBytes)
            //               select new Tuple<PagePointer, PagePointer>(pagePointer, pageHeader.Pointer)
            //              ).ToList();

            //File.WriteAllText("test.loc.txt", string.Join(Environment.NewLine, result.Select(x => x.Item1 + " -> " + x.Item2)));


            if (_backupPagesMap.TryGetValue(loc.FileID, out var loc1) && loc1.TryGetValue(loc.PageID / 8, out var loc2))
            {
                return(_bufferManager.GetPageBytes(loc2.FileID, loc2.PageID + loc.PageID % 8, putResultToCache));
            }

            var pointer = BinarySearch(x => new PageHeader(_bufferManager.GetHeaderBytes(loc.FileID, x * 8)).Pointer,
                                       0, (long)_bufferManager.GetFileLen(loc.FileID) / (8192 * 8), loc);

            return(_bufferManager.GetPageBytes(pointer.FileID, pointer.PageID + loc.PageID % 8, putResultToCache));
        }
Exemplo n.º 2
0
        internal PrimaryRecordPage GetPrimaryRecordPage(PagePointer loc, CompressionContext compression)
        {
            Debug.WriteLine("Loading Primary Record Page " + loc);

            return(new PrimaryRecordPage(bufferManager.GetPageBytes(loc.FileID, loc.PageID), compression, this));
        }