You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by GitBox <gi...@apache.org> on 2022/06/22 06:03:14 UTC

[GitHub] [avro] clesaec commented on a diff in pull request #1719: AVRO-3531:datum reader thread safe

clesaec commented on code in PR #1719:
URL: https://github.com/apache/avro/pull/1719#discussion_r903314428


##########
lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumReader.java:
##########
@@ -498,32 +500,72 @@ protected Class findStringClass(Schema schema) {
     }
   }
 
-  private Map<Schema, Class> stringClassCache = new IdentityHashMap<>();
+  protected static class ReaderCache {
+    private final Map<Schema, Class> stringClassCache = new IdentityHashMap<>();
 
-  private Class getStringClass(Schema s) {
-    Class c = stringClassCache.get(s);
-    if (c == null) {
-      c = findStringClass(s);
-      stringClassCache.put(s, c);
+    private final Map<Class, Function<String, Object>> stringCtorCache = new ConcurrentHashMap<>();

Review Comment:
   I will try that, but identityHashMap is also optimized by the fact it stores key & object in a single array.



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org