martin-g commented on a change in pull request #1301:
URL: https://github.com/apache/avro/pull/1301#discussion_r698395051
##########
File path: lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java
##########
@@ -69,6 +69,16 @@
private static final GenericData INSTANCE = new GenericData();
+ private static final Map<Class<?>, String> PRIMATIVE_DATUM_TYPES = new
IdentityHashMap<>();
Review comment:
Any reason to use IdentityHashMap in favour of HashMap ?
##########
File path: lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java
##########
@@ -892,6 +902,9 @@ public int resolveUnion(Schema union, Object datum) {
protected String getSchemaName(Object datum) {
if (datum == null || datum == JsonProperties.NULL_VALUE)
return Type.NULL.getName();
+ String primativeType = PRIMATIVE_DATUM_TYPES.get(datum.getClass());
+ if (primativeType != null)
+ return primativeType;
Review comment:
Shouldn't we remove the later checks for `isInteger(datum)`,
`isLong(datum)`, etc. ?
--
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]