public async Task <IndexAllocationMap> GetAllocation(int databaseId, PageAddress pageAddress) { var allocation = new IndexAllocationMap(); await BuildAllocationChain(allocation, databaseId, pageAddress); return(allocation); }
private async Task BuildAllocationChain(IndexAllocationMap allocationMap, int databaseId, PageAddress pageAddress) { while (true) { var page = await GetAllocationPage(databaseId, pageAddress); if (page.Header.PageType != PageType.Iam) { Log.Error($"Page {pageAddress} is not an IAM page"); return; } allocationMap.Pages.Add(page); allocationMap.SinglePageSlots.AddRange(page.SinglePageSlots); if (page.Header.NextPage != PageAddress.Empty) { pageAddress = page.Header.NextPage; continue; } break; } }