public void AddOrUpdateEntry(PageSummary summary) { if (!indices.Keys.Contains(summary.AddressSpaceId)) { indices[summary.AddressSpaceId] = new List <PageSummary>(); } if (!summary.PageFileIndex.HasValue) { stream.Position = stream.Length; indices[summary.AddressSpaceId].Add(summary); endOfIndex = Math.Max((summary.DataFileOffset + summary.Size), endOfIndex); } else { stream.Position = summary.PageFileIndex.Value; if (!indices[summary.AddressSpaceId].Contains(summary)) { //foreach (var space in indices.Values) //{ // if (space.Contains(summary)) space.Remove(summary); //} EmptyPages.Remove(summary); indices[summary.AddressSpaceId].Add(summary); summary.Allocated = true; } } summary.WriteToStream(writer); }
public void ExpandAddressSpace(Guid addressSpaceId, long localOffset) { if (!EmptyPages.Any()) { IndexFileGrowth(); } PageSummary summary = EmptyPages[0]; summary.AddressSpaceId = addressSpaceId; summary.LocalAddressSpaceOffset = localOffset; AddOrUpdateEntry(summary); }