internal CompressedRecordPage GetCompressedRecordPage(PagePointer loc, CompressionContext compression) { if (compression.CompressionLevel == CompressionLevel.None) { throw new ArgumentException("Can't load compressed page with a compression level of none."); } Debug.WriteLine("Loading compressed record page " + loc); return(new CompressedRecordPage(GetPageBytes(loc), compression, this)); }
internal GamPage GetGamPage(PagePointer loc) { Debug.WriteLine("Loading GAM Page " + loc); if (loc.PageID % 511230 != 2) { throw new ArgumentException("Invalid GAM index: " + loc.PageID); } return(new GamPage(GetPageBytes(loc), this)); }
internal PfsPage GetPfsPage(PagePointer loc) { Debug.WriteLine("Loading PFS Page " + loc); // We know PFS pages are present every 8088th page, except for the very first one if (loc.PageID != 1 && loc.PageID % 8088 != 0) { throw new ArgumentException("Invalid PFS index: " + loc.PageID); } return(new PfsPage(GetPageBytes(loc), this)); }
/// <summary> /// Starts at the data page (loc) and follows the NextPage pointer chain till the end. /// </summary> internal IEnumerable <Row> ScanLinkedNonclusteredIndexPages(PagePointer loc, Row schema, CompressionContext compression) { while (loc != PagePointer.Zero) { var page = Database.GetNonclusteredIndexPage(loc); foreach (var dr in page.GetEntities(schema, compression)) { yield return(dr); } loc = page.Header.NextPage; } }
/// <summary> /// Starts at the data page (loc) and follows the NextPage pointer chain till the end. /// </summary> internal IEnumerable <Row> ScanLinkedDataPages(PagePointer loc, DataExtractorHelper schema, CompressionContext compression, bool isSysTable) { while (PagePointer.Zero != loc && loc != null && loc.PageID > 0) { var recordParser = RecordEntityParser.CreateEntityParserForPage(loc, compression, Database, isSysTable); foreach (var dr in recordParser.GetEntities(schema)) { yield return(dr); } loc = recordParser.NextPage; } }
internal IamPage GetIamPage(PagePointer loc, bool useCache) { Debug.WriteLine("Loading IAM Page " + loc); return(new IamPage(GetPageBytes(loc, useCache), this)); }
internal TextMixPage GetTextMixPage(PagePointer loc) { Debug.WriteLine("Loading TextMix Page " + loc); return(new TextMixPage(GetPageBytes(loc, false), this)); }
internal ClusteredIndexPage GetClusteredIndexPage(PagePointer loc, bool isSysTable) { Debug.WriteLine("Loading Clustered Index Page " + loc); return(new ClusteredIndexPage(GetPageBytes(loc, isSysTable), this)); }
internal NonclusteredIndexPage GetNonclusteredIndexPage(PagePointer loc) { Debug.WriteLine("Loading Nonclustered Index Page " + loc); return(new NonclusteredIndexPage(GetPageBytes(loc), this)); }
internal FileHeaderPage GetFileHeaderPage(PagePointer loc) { Debug.WriteLine("Loading File Header Page"); return(new FileHeaderPage(GetPageBytes(loc), this)); }
internal Page GetPage(PagePointer loc) { Debug.WriteLine("Loading Generic Page " + loc); return(new Page(GetPageBytes(loc), this)); }
private byte[] GetPageBytes(PagePointer pagePointer, bool putResultsToCache = true) { return(_bufferManager.GetPageBytes(pagePointer.FileID, pagePointer.PageID, putResultsToCache)); }
internal PrimaryRecordPage GetPrimaryRecordPage(PagePointer loc, CompressionContext compression, bool isSysTable = true) { Debug.WriteLine("Loading Primary Record Page " + loc); return(new PrimaryRecordPage(GetPageBytes(loc, isSysTable), compression, this)); }
public ExtentPointer(PagePointer start) { StartPage = start; EndPage = new PagePointer(start.FileID, start.PageID + 7); }
/// <summary> /// Scans a linked list of pages returning an IEnumerable of typed rows with data & schema /// </summary> internal IEnumerable <TDataRow> ScanLinkedDataPages <TDataRow>(PagePointer loc, CompressionContext compression) where TDataRow : Row, new() { return(ScanLinkedDataPages(loc, new DataExtractorHelper(new TDataRow()), compression, true).Cast <TDataRow>()); }
/// <summary> /// Scans a heap beginning from the provided IAM page and onwards. /// </summary> private IEnumerable <Row> ScanHeap(PagePointer loc, DataExtractorHelper schema, CompressionContext compression, bool isSysTable) { // Traverse the linked list of IAM pages until 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, isSysTable); // 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, isSysTable); 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, isSysTable); foreach (var dr in recordParser.GetEntities(schema)) { yield return(dr); } } } // Update current IAM chain location to the tail pointer loc = iamPage.Header.NextPage; } }