public void GetPfsPointerForPage() { Assert.AreEqual(new PagePointer(1, 1), PfsPage.GetPfsPointerForPage(new PagePointer(1, 27))); Assert.AreEqual(new PagePointer(1, 1), PfsPage.GetPfsPointerForPage(new PagePointer(1, 0))); Assert.AreEqual(new PagePointer(1, 1), PfsPage.GetPfsPointerForPage(new PagePointer(1, 8087))); Assert.AreEqual(new PagePointer(1, 8088), PfsPage.GetPfsPointerForPage(new PagePointer(1, 8088))); Assert.AreEqual(new PagePointer(1, 8088), PfsPage.GetPfsPointerForPage(new PagePointer(1, 8089))); }
/// <summary> /// Sets the PFS page to be displayed /// </summary> /// <param name="pageAddress">The page address.</param> /// <param name="databaseName">Name of the database.</param> /// <param name="connectionString">The connection string.</param> public void SetPfsPage(PageAddress pageAddress, string databaseName, string connectionString) { topPanel.Visible = false; var pfsPage = new PfsPage(connectionString, databaseName, pageAddress); allocationMap.Mode = MapMode.Pfs; allocationMap.Pfs = new Pfs(pfsPage); allocationMap.ExtentCount = 1011; allocationMap.ExtentSize = AllocationMap.Large; if (pfsPage.PageAddress.PageId > 1) { allocationMap.StartPage = pfsPage.PageAddress; } else { allocationMap.StartPage = new PageAddress(pfsPage.PageAddress.FileId, 0); } allocationMap.Invalidate(); }
/// <summary> /// Scans a heap beginning from the provided IAM page and onwards. /// </summary> private IEnumerable <Row> scanHeap(PagePointer loc, Row schema, CompressionContext compression) { // Traverse the linked list of IAM pages untill the tail pointer is zero while (loc != PagePointer.Zero) { // Before scanning, check that the IAM page itself is allocated var pfsPage = Database.GetPfsPage(PfsPage.GetPfsPointerForPage(loc)); // If IAM page isn't allocated, there's nothing to return if (!pfsPage.GetPageDescription(loc.PageID).IsAllocated) { yield break; } var iamPage = Database.GetIamPage(loc); // Create an array with all of the header slot pointers var iamPageSlots = new[] { iamPage.Slot0, iamPage.Slot1, iamPage.Slot2, iamPage.Slot3, iamPage.Slot4, iamPage.Slot5, iamPage.Slot6, iamPage.Slot7 }; // Loop each header slot and yield the results, provided the header slot is allocated foreach (var slot in iamPageSlots.Where(x => x != PagePointer.Zero)) { var recordParser = RecordEntityParser.CreateEntityParserForPage(slot, compression, Database); foreach (var dr in recordParser.GetEntities(schema)) { yield return(dr); } } // Then loop through allocated extents and yield results foreach (var extent in iamPage.GetAllocatedExtents()) { // Get PFS page that tracks this extent var pfs = Database.GetPfsPage(PfsPage.GetPfsPointerForPage(extent.StartPage)); foreach (var pageLoc in extent.GetPagePointers()) { // Check if page is allocated according to PFS page var pfsDescription = pfs.GetPageDescription(pageLoc.PageID); if (!pfsDescription.IsAllocated) { continue; } var recordParser = RecordEntityParser.CreateEntityParserForPage(pageLoc, compression, Database); foreach (var dr in recordParser.GetEntities(schema)) { yield return(dr); } } } // Update current IAM chain location to the tail pointer loc = iamPage.Header.NextPage; } }
public Pfs(PfsPage page) { pfsPages = new List <PfsPage>(); pfsPages.Add(page); }