avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r1725668 - /avro/trunk/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java
Date Wed, 20 Jan 2016 04:19:31 GMT
Author: blue
Date: Wed Jan 20 04:19:31 2016
New Revision: 1725668

URL: http://svn.apache.org/viewvc?rev=1725668&view=rev
Log:
AVRO-1781 ADDENDUM: Remove LogicalTypes cache.

This cache maps a Schema to its corresponding LogicalType that has been
constructed from the Schema's properties, by object identity. This is no
longer needed now that the LogicalType is set on the schema instance
when it is parsed. The cache was necessary when we were trying to avoid
all changes to the Schema class.

Modified:
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java?rev=1725668&r1=1725667&r2=1725668&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java (original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java Wed Jan 20 04:19:31
2016
@@ -20,15 +20,9 @@ package org.apache.avro;
 
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-import com.google.common.base.Optional;
-import com.google.common.collect.MapMaker;
 
 public class LogicalTypes {
 
-  private static final Map<Schema, Optional<LogicalType>> CACHE = new MapMaker()
-      .weakKeys()
-      .makeMap();
-
   public interface LogicalTypeFactory {
     LogicalType fromSchema(Schema schema);
   }
@@ -54,16 +48,7 @@ public class LogicalTypes {
   }
 
   public static LogicalType fromSchemaIgnoreInvalid(Schema schema) {
-    if (CACHE.containsKey(schema)) {
-      return CACHE.get(schema).orNull();
-    }
-
-    LogicalType logicalType = fromSchemaImpl(schema, false);
-
-    // add to the cache, even if it is null
-    CACHE.put(schema, Optional.fromNullable(logicalType));
-
-    return logicalType;
+    return fromSchemaImpl(schema, false);
   }
 
   private static LogicalType fromSchemaImpl(Schema schema, boolean throwErrors) {



Mime
View raw message