Polishing.

Move all primary interaction API into TypeInformation to prepare making all implementations package protected. Adapt all deprecated API usage in Spring Data Commons to the new one.

Benchmark results look as follows:

2.7
                                                                                                Mode  Cnt          Score          Error  Units
TypicalEntityReaderBenchmark.hasReadTarget                                                     thrpt   10   81982861,995 ±   269948,368  ops/s
TypicalEntityReaderBenchmark.kotlinDataClass                                                   thrpt   10   18472975,689 ±   161234,912  ops/s
TypicalEntityReaderBenchmark.kotlinDataClassWithDefaulting                                     thrpt   10    4029631,568 ±    18990,863  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedConstructorAndField                          thrpt   10   11495517,933 ±   209269,454  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedConstructorAndProperty                       thrpt   10   11192152,036 ±   249721,563  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedConstructorArgsCreation                      thrpt   10   18835101,279 ±    81895,338  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedFieldAccess                                  thrpt   10   16309896,939 ±    80376,406  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedPropertyAccess                               thrpt   10   15471691,537 ±    52426,121  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorAndField                         thrpt   10   12080159,283 ±    49922,326  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorAndProperty                      thrpt   10   12166160,066 ±   173876,051  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorArgsCreation                     thrpt   10   13548906,437 ±   485944,886  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveFieldAccess                                 thrpt   10   16457347,670 ±    64170,567  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccess                              thrpt   10   14115878,948 ±    57491,268  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccessWithCustomConversionRegistry  thrpt   10   15137904,257 ±    51148,726  ops/s

DefaultTypeMapperBenchmark.readTyped                                                           thrpt   10  146820080,682 ± 13254238,407  ops/s
DefaultTypeMapperBenchmark.readTypedWithBaseType                                               thrpt   10   55420351,827 ±  1888634,217  ops/s
DefaultTypeMapperBenchmark.readUntyped                                                         thrpt   10  193934847,273 ±   442867,276  ops/s
DefaultTypeMapperBenchmark.readUntypedWithBaseType                                             thrpt   10  192032977,366 ±  4300192,665  ops/s

3.0 – Before this change
                                                                                                Mode  Cnt          Score         Error  Units
TypicalEntityReaderBenchmark.hasReadTarget                                                     thrpt   10   81124249,138 ±  174095,495  ops/s
TypicalEntityReaderBenchmark.kotlinDataClass                                                   thrpt   10   18685936,220 ±  243939,063  ops/s
TypicalEntityReaderBenchmark.kotlinDataClassWithDefaulting                                     thrpt   10    4125709,048 ±   17615,890  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedConstructorAndField                          thrpt   10   12277837,989 ±   96973,908  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedConstructorAndProperty                       thrpt   10   12419978,391 ±   45780,658  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedConstructorArgsCreation                      thrpt   10   18744593,010 ±   71655,735  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedFieldAccess                                  thrpt   10   16497286,465 ±   41150,718  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedPropertyAccess                               thrpt   10   15639640,554 ±   69758,391  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorAndField                         thrpt   10   11715068,503 ±   66085,900  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorAndProperty                      thrpt   10   12159285,083 ±   58171,950  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorArgsCreation                     thrpt   10   13711647,512 ±   66496,271  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveFieldAccess                                 thrpt   10   16287057,838 ±   54826,532  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccess                              thrpt   10   13847665,634 ±  127834,292  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccessWithCustomConversionRegistry  thrpt   10   15099300,270 ±   89030,403  ops/s

DefaultTypeMapperBenchmark.readTyped                                                           thrpt   10  151893972,774 ±  494555,250  ops/s
DefaultTypeMapperBenchmark.readTypedWithBaseType                                               thrpt   10   55869432,892 ±  389099,409  ops/s
DefaultTypeMapperBenchmark.readUntyped                                                         thrpt   10  192661151,755 ± 1075079,924  ops/s
DefaultTypeMapperBenchmark.readUntypedWithBaseType                                             thrpt   10  192315554,269 ± 3061160,314  ops/s

3.0 – After this change
                                                                                                Mode  Cnt          Score         Error  Units
TypicalEntityReaderBenchmark.hasReadTarget                                                     thrpt   10   82650245,236 ±  321384,577  ops/s
TypicalEntityReaderBenchmark.kotlinDataClass                                                   thrpt   10   21304680,430 ±  396764,834  ops/s
TypicalEntityReaderBenchmark.kotlinDataClassWithDefaulting                                     thrpt   10    4422187,275 ±   35088,721  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedConstructorAndField                          thrpt   10   13345503,496 ±  180490,423  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedConstructorAndProperty                       thrpt   10   13911653,366 ±  266028,886  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedConstructorArgsCreation                      thrpt   10   21192316,261 ±  356534,938  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedFieldAccess                                  thrpt   10   17533419,173 ±   49226,408  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedPropertyAccess                               thrpt   10   17393382,078 ±  114774,442  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorAndField                         thrpt   10   12867285,952 ±   62870,980  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorAndProperty                      thrpt   10   13208453,130 ±  272795,070  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorArgsCreation                     thrpt   10   14998467,714 ±   84265,782  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveFieldAccess                                 thrpt   10   17365982,413 ±  115287,403  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccess                              thrpt   10   15503841,949 ±  123631,592  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccessWithCustomConversionRegistry  thrpt   10   15716685,449 ±   64686,646  ops/s

DefaultTypeMapperBenchmark.readTyped                                                           thrpt   10  154433835,941 ± 1391455,835  ops/s
DefaultTypeMapperBenchmark.readTypedWithBaseType                                               thrpt   10   77919886,633 ±  438244,738  ops/s
DefaultTypeMapperBenchmark.readUntyped                                                         thrpt   10  194435210,217 ±  936274,571  ops/s
DefaultTypeMapperBenchmark.readUntypedWithBaseType                                             thrpt   10  193768718,043 ±  475103,167  ops/s

Original pull request: #2572.
Related ticket: #2312.
This commit is contained in:
Oliver Drotbohm
2022-04-06 14:46:18 +02:00
parent 1d6331ccb6
commit 07342cffb5
60 changed files with 655 additions and 678 deletions

View File

@@ -68,7 +68,7 @@ public class PropertyPath implements Streamable<PropertyPath> {
* @param owningType must not be {@literal null}.
*/
PropertyPath(String name, Class<?> owningType) {
this(name, ClassTypeInformation.from(owningType), Collections.emptyList());
this(name, TypeInformation.of(owningType), Collections.emptyList());
}
/**
@@ -315,7 +315,7 @@ public class PropertyPath implements Streamable<PropertyPath> {
* @return
*/
public static PropertyPath from(String source, Class<?> type) {
return from(source, ClassTypeInformation.from(type));
return from(source, TypeInformation.of(type));
}
/**

View File

@@ -189,7 +189,7 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
@Nullable
public E getPersistentEntity(Class<?> type) {
return getPersistentEntity(ClassTypeInformation.from(type));
return getPersistentEntity(TypeInformation.of(type));
}
@Override
@@ -197,7 +197,7 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
Assert.notNull(type, "Type must not be null");
TypeInformation<?> typeInformation = ClassTypeInformation.from(type);
TypeInformation<?> typeInformation = TypeInformation.of(type);
try {
@@ -312,7 +312,7 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
*/
protected final <T> PersistentPropertyPaths<T, P> doFindPersistentPropertyPaths(Class<T> type,
Predicate<? super P> predicate, Predicate<P> traversalGuard) {
return persistentPropertyPathFactory.from(ClassTypeInformation.from(type), predicate, traversalGuard);
return persistentPropertyPathFactory.from(TypeInformation.of(type), predicate, traversalGuard);
}
/**
@@ -322,7 +322,7 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
* @return
*/
protected Optional<E> addPersistentEntity(Class<?> type) {
return addPersistentEntity(ClassTypeInformation.from(type));
return addPersistentEntity(TypeInformation.of(type));
}
/**
@@ -728,7 +728,7 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
*/
public PropertyMatch(@Nullable String namePattern, @Nullable String typeName) {
Assert.isTrue(!(namePattern == null && typeName == null), "Either name pattern or type name must be given");
Assert.isTrue(!((namePattern == null) && (typeName == null)), "Either name pattern or type name must be given");
this.namePattern = namePattern;
this.typeName = typeName;
@@ -746,11 +746,11 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
Assert.notNull(name, "Name must not be null");
Assert.notNull(type, "Type must not be null");
if (namePattern != null && !name.matches(namePattern)) {
if ((namePattern != null) && !name.matches(namePattern)) {
return false;
}
if (typeName != null && !type.getName().equals(typeName)) {
if ((typeName != null) && !type.getName().equals(typeName)) {
return false;
}

View File

@@ -68,7 +68,7 @@ class PersistentPropertyPathFactory<E extends PersistentEntity<?, P>, P extends
Assert.notNull(type, "Type must not be null");
Assert.notNull(propertyPath, "Property path must not be null");
return getPersistentPropertyPath(ClassTypeInformation.from(type), propertyPath);
return getPersistentPropertyPath(TypeInformation.of(type), propertyPath);
}
/**
@@ -112,7 +112,7 @@ class PersistentPropertyPathFactory<E extends PersistentEntity<?, P>, P extends
Assert.notNull(type, "Type must not be null");
Assert.notNull(propertyFilter, "Property filter must not be null");
return from(ClassTypeInformation.from(type), propertyFilter);
return from(TypeInformation.of(type), propertyFilter);
}
/**
@@ -131,7 +131,7 @@ class PersistentPropertyPathFactory<E extends PersistentEntity<?, P>, P extends
Assert.notNull(propertyFilter, "Property filter must not be null");
Assert.notNull(traversalGuard, "Traversal guard must not be null");
return from(ClassTypeInformation.from(type), propertyFilter, traversalGuard);
return from(TypeInformation.of(type), propertyFilter, traversalGuard);
}
/**

View File

@@ -88,7 +88,7 @@ public abstract class AnnotationBasedPersistentProperty<P extends PersistentProp
return Optional.of(Reference.class) //
.map(this::findAnnotation) //
.map(Reference::to) //
.map(it -> !Class.class.equals(it) ? ClassTypeInformation.from(it) : getActualTypeInformation()) //
.map(it -> !Class.class.equals(it) ? TypeInformation.of(it) : getActualTypeInformation()) //
.orElseGet(() -> super.getAssociationTargetTypeInformation());
});

View File

@@ -63,7 +63,7 @@ public interface PreferredConstructorDiscoverer<T, P extends PersistentProperty<
Assert.notNull(type, "Type must not be null");
return Discoverers.findDiscoverer(type) //
.discover(ClassTypeInformation.from(type), null);
.discover(TypeInformation.of(type), null);
}
/**