public HistoryStateTypeChanges(HollowHistoricalState historicalState, String typeName, HollowHistoryRecordNamer recordNamer, String... groupedFieldNames) {
this.stateVersion = historicalState.getVersion();
this.typeName = typeName;
this.groupedFieldNames = groupedFieldNames;
this.modifiedRecords = new RecordDiffTreeNode("", "Modified", "Modified", historicalState, recordNamer);
this.addedRecords = new RecordDiffTreeNode("", "Added", "Added", historicalState, recordNamer);
this.removedRecords = new RecordDiffTreeNode("", "Removed", "Removed", historicalState, recordNamer);
HollowHistoricalStateTypeKeyOrdinalMapping typeKeyMapping = historicalState.getKeyOrdinalMapping().getTypeMappings().get(typeName);
HollowObjectTypeDataAccess dataAccess = (HollowObjectTypeDataAccess) historicalState.getDataAccess().getTypeDataAccess(typeName);
int[] groupedFieldIndexes = getGroupedFieldIndexes(groupedFieldNames, typeKeyMapping.getKeyIndex().getKeyFields());
IntMapEntryIterator removedIter = typeKeyMapping.removedOrdinalMappingIterator();
IntMapEntryIterator addedIter = typeKeyMapping.addedOrdinalMappingIterator();
while(removedIter.next()) {
int fromOrdinal = removedIter.getValue();
int toOrdinal = typeKeyMapping.findAddedOrdinal(removedIter.getKey());
if(toOrdinal != -1) {
addRecordDiff(modifiedRecords, historicalState, typeKeyMapping, recordNamer, dataAccess, removedIter.getKey(), fromOrdinal, toOrdinal, groupedFieldIndexes);
} else {
addRecordDiff(removedRecords, historicalState, typeKeyMapping, recordNamer, dataAccess, removedIter.getKey(), fromOrdinal, toOrdinal, groupedFieldIndexes);
}
}
while(addedIter.next()) {
if(typeKeyMapping.findRemovedOrdinal(addedIter.getKey()) == -1) {
int toOrdinal = addedIter.getValue();
addRecordDiff(addedRecords, historicalState, typeKeyMapping, recordNamer, dataAccess, addedIter.getKey(), -1, toOrdinal, groupedFieldIndexes);
}
}
}