opwvhk commented on code in PR #2581:
URL: https://github.com/apache/avro/pull/2581#discussion_r1391265121
##########
lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java:
##########
@@ -845,20 +859,25 @@ public static Schema makeNullable(Schema schema) {
private static final ConcurrentMap<Class<?>, Field[]> FIELDS_CACHE = new
ConcurrentHashMap<>();
+ private static final ConcurrentMap<Class<?>, Field[]> NATIVE_FIELDS_CACHE =
new ConcurrentHashMap<>();
+
// Return of this class and its superclasses to serialize.
- private static Field[] getCachedFields(Class<?> recordClass) {
- return MapUtil.computeIfAbsent(FIELDS_CACHE, recordClass, rc ->
getFields(rc, true));
+ private static Field[] getCachedFields(Class<?> recordClass, boolean
orderBy) {
+ return MapUtil.computeIfAbsent(orderBy ? FIELDS_CACHE :
NATIVE_FIELDS_CACHE, recordClass,
+ rc -> getFields(rc, true, orderBy));
}
- private static Field[] getFields(Class<?> recordClass, boolean excludeJava) {
+ private static Field[] getFields(Class<?> recordClass, boolean excludeJava,
boolean orderBy) {
Review Comment:
```suggestion
private static Field[] getFields(Class<?> recordClass, boolean
excludeJava, boolean useDeterministicFieldOrder) {
```
As `orderBy` is a boolean, it's not a standard "order by X". Can we please
rename it?
More than a name like `sortFields`, the name `useDeterministicFieldOrder`
captures the fact that a JVM is free to scramble the field order as it sees fit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]