// internal for testing internal static void CalculateDeltaRowCountsForGeneration(RowCounts[][] rowCounts, int generation, ref EnCMapTableReader encMapTable) { foreach (var tableRowCounts in rowCounts) { tableRowCounts[generation].AggregateInserts = tableRowCounts[generation - 1].AggregateInserts; } int mapRowCount = encMapTable.NumberOfRows; for (int mapRid = 1; mapRid <= mapRowCount; mapRid++) { uint token = encMapTable.GetToken(mapRid); int rid = (int)(token & TokenTypeIds.RIDMask); var tableRowCounts = rowCounts[token >> TokenTypeIds.RowIdBitCount]; if (rid > tableRowCounts[generation].AggregateInserts) { if (rid != tableRowCounts[generation].AggregateInserts + 1) { throw new BadImageFormatException(SR.EnCMapNotSorted); } // insert: tableRowCounts[generation].AggregateInserts = rid; } else { // update: tableRowCounts[generation].Updates++; } } }