public List <long> GetAllIdsInSectionContaining(long id) { if (Contains(id) == false) { var posInPage = (int)(id % Constants.Storage.PageSize); var pageNumberInSection = (id - posInPage) / Constants.Storage.PageSize; var pageHeaderForId = PageHeaderFor(pageNumberInSection); // this is in another section, cannot free it directly, so we'll forward to the right section var sectionPageNumber = pageHeaderForId->PageNumber - pageHeaderForId->PageNumberInSection - 1; var actualSection = new RawDataSection(_tx, sectionPageNumber); if (actualSection._sectionHeader->SectionOwnerHash != _sectionHeader->SectionOwnerHash) { VoronUnrecoverableErrorException.Raise(_tx.Environment, $"Cannot get all ids in section containing {id} because the raw data section starting in {sectionPageNumber} belongs to a different owner"); } return(actualSection.GetAllIdsInSectionContaining(id)); } var ids = new List <long>(_sectionHeader->NumberOfEntries); for (int i = 0; i < _sectionHeader->NumberOfPages && ids.Count < _sectionHeader->NumberOfEntries; i++) { FillAllIdsInPage(_sectionHeader->PageNumber + i, ids); } return(ids); }
public List <long> GetAllIdsInSectionContaining(long id) { if (Contains(id) == false) { var posInPage = (int)(id % Constants.Storage.PageSize); var pageNumberInSection = (id - posInPage) / Constants.Storage.PageSize; var pageHeaderForId = PageHeaderFor(pageNumberInSection); // this is in another section, cannot free it directly, so we'll forward to the right section var sectionPageNumber = pageHeaderForId->PageNumber - pageHeaderForId->PageNumberInSection - 1; var actualSection = new RawDataSection(_tx, sectionPageNumber); if (actualSection._sectionHeader->SectionOwnerHash != _sectionHeader->SectionOwnerHash) { VoronUnrecoverableErrorException.Raise(_tx.Environment, $"Cannot get all ids in section containing {id} because the raw data section starting in {sectionPageNumber} belongs to a different owner"); } return(actualSection.GetAllIdsInSectionContaining(id)); } var ids = new List <long>(_sectionHeader->NumberOfEntries); for (int i = 0; i < _sectionHeader->NumberOfPages && ids.Count < _sectionHeader->NumberOfEntries; i++) { var pageHeader = PageHeaderFor(_sectionHeader->PageNumber + i + 1); var offset = sizeof(RawDataSmallPageHeader); while (offset < Constants.Storage.PageSize) { var sizes = (RawDataEntrySizes *)((byte *)pageHeader + offset); if (sizes->UsedSize != -1) { var currentId = (pageHeader->PageNumber * Constants.Storage.PageSize) + offset; var posInPage = (int)(currentId % Constants.Storage.PageSize); if (posInPage >= pageHeader->NextAllocation) { break; } ids.Add(currentId); if (ids.Count == _sectionHeader->NumberOfEntries) { break; } } offset += sizeof(short) * 2 + sizes->AllocatedSize; } } return(ids); }