Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 07342cf

Browse files
committedJun 10, 2022
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.
1 parent 1d6331c commit 07342cf

File tree

60 files changed

+653
-676
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+653
-676
lines changed
 

‎src/main/java/org/springframework/data/convert/ConfigurableTypeInformationMapper.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.springframework.data.mapping.Alias;
2323
import org.springframework.data.mapping.PersistentEntity;
2424
import org.springframework.data.mapping.context.MappingContext;
25-
import org.springframework.data.util.ClassTypeInformation;
2625
import org.springframework.data.util.TypeInformation;
2726
import org.springframework.lang.Nullable;
2827
import org.springframework.util.Assert;
@@ -37,8 +36,8 @@
3736
*/
3837
public class ConfigurableTypeInformationMapper implements TypeInformationMapper {
3938

40-
private final Map<ClassTypeInformation<?>, Alias> typeToAlias;
41-
private final Map<Alias, ClassTypeInformation<?>> aliasToType;
39+
private final Map<TypeInformation<?>, Alias> typeToAlias;
40+
private final Map<Alias, TypeInformation<?>> aliasToType;
4241

4342
/**
4443
* Creates a new {@link ConfigurableTypeInformationMapper} for the given type map.
@@ -54,7 +53,7 @@ public ConfigurableTypeInformationMapper(Map<? extends Class<?>, String> sourceT
5453

5554
for (Entry<? extends Class<?>, String> entry : sourceTypeMap.entrySet()) {
5655

57-
ClassTypeInformation<?> type = ClassTypeInformation.from(entry.getKey());
56+
TypeInformation<?> type = TypeInformation.of(entry.getKey());
5857
Alias alias = Alias.of(entry.getValue());
5958

6059
if (typeToAlias.containsValue(alias)) {

‎src/main/java/org/springframework/data/convert/DefaultTypeMapper.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.springframework.data.mapping.Alias;
2828
import org.springframework.data.mapping.PersistentEntity;
2929
import org.springframework.data.mapping.context.MappingContext;
30-
import org.springframework.data.util.ClassTypeInformation;
3130
import org.springframework.data.util.TypeInformation;
3231
import org.springframework.lang.Nullable;
3332
import org.springframework.util.Assert;
@@ -149,16 +148,16 @@ public <T> TypeInformation<? extends T> readType(S source, TypeInformation<T> ba
149148

150149
Class<T> rawType = basicType.getType();
151150

152-
boolean isMoreConcreteCustomType = rawType == null
153-
|| rawType.isAssignableFrom(documentsTargetType) && !rawType.equals(documentsTargetType);
151+
boolean isMoreConcreteCustomType = (rawType == null)
152+
|| (rawType.isAssignableFrom(documentsTargetType) && !rawType.equals(documentsTargetType));
154153

155154
if (!isMoreConcreteCustomType) {
156155
return basicType;
157156
}
158157

159-
ClassTypeInformation<?> targetType = ClassTypeInformation.from(documentsTargetType);
158+
TypeInformation<?> targetType = TypeInformation.of(documentsTargetType);
160159

161-
return (TypeInformation<? extends T>) basicType.specialize(targetType);
160+
return basicType.specialize(targetType);
162161
}
163162

164163
/**
@@ -190,7 +189,7 @@ protected TypeInformation<?> getFallbackTypeFor(S source) {
190189

191190
@Override
192191
public void writeType(Class<?> type, S dbObject) {
193-
writeType(ClassTypeInformation.from(type), dbObject);
192+
writeType(TypeInformation.of(type), dbObject);
194193
}
195194

196195
@Override

0 commit comments

Comments
 (0)