Exemple #1
0
        /// <summary>
        /// Starts at the data page (loc) and follows the NextPage pointer chain till the end.
        /// </summary>
        internal IEnumerable <Row> ScanLinkedDataPages(PagePointer loc, Row schema, CompressionContext compression)
        {
            while (loc != PagePointer.Zero)
            {
                var recordParser = RecordEntityParser.CreateEntityParserForPage(loc, compression, Database);

                foreach (var dr in recordParser.GetEntities(schema))
                {
                    yield return(dr);
                }

                loc = recordParser.NextPage;
            }
        }
Exemple #2
0
        /// <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;
            }
        }
Exemple #3
0
        /// <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;
            }
        }