Skip to content

Commit

Permalink
HHH-14305 Memory optimisation for AbstractPropertyMapping#duplicateIn…
Browse files Browse the repository at this point in the history
…compatiblePaths
  • Loading branch information
Sanne committed Nov 1, 2020
1 parent 13398a8 commit d6108fa
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ public abstract class AbstractPropertyMapping implements PropertyMapping {
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( AbstractPropertyMapping.class );

private final Map<String, Type> typesByPropertyPath = new HashMap<>();
private final Set<String> duplicateIncompatiblePaths = new HashSet<>();

//This field is only used during initialization, no need for threadsafety:
//FIXME get rid of the field, or at least clear it after boot? Not urgent as we typically won't initialize it at all.
private Set<String> duplicateIncompatiblePaths = null;

private final Map<String, String[]> columnsByPropertyPath = new HashMap<>();
private final Map<String, String[]> columnReadersByPropertyPath = new HashMap<>();
private final Map<String, String[]> columnReaderTemplatesByPropertyPath = new HashMap<>();
Expand Down Expand Up @@ -168,7 +172,7 @@ protected void addPropertyPath(
String[] formulaTemplates,
Mapping factory) {
Type existingType = typesByPropertyPath.get( path );
if ( existingType != null || duplicateIncompatiblePaths.contains( path ) ) {
if ( existingType != null || ( duplicateIncompatiblePaths != null && duplicateIncompatiblePaths.contains( path ) ) ) {
// If types match or the new type is not an association type, there is nothing for us to do
if ( type == existingType || existingType == null || !( type instanceof AssociationType ) ) {
logDuplicateRegistration( path, existingType, type );
Expand Down Expand Up @@ -212,6 +216,9 @@ else if ( type instanceof EntityType && existingType instanceof EntityType ) {
logIncompatibleRegistration( path, existingType, type );
}
if ( commonType == null ) {
if ( duplicateIncompatiblePaths == null ) {
duplicateIncompatiblePaths = new HashSet<>();
}
duplicateIncompatiblePaths.add( path );
typesByPropertyPath.remove( path );
// Set everything to empty to signal action has to be taken!
Expand Down

0 comments on commit d6108fa

Please sign in to comment.