avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomwh...@apache.org
Subject svn commit: r1725916 - /avro/branches/branch-1.8/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java
Date Thu, 21 Jan 2016 12:06:23 GMT
Author: tomwhite
Date: Thu Jan 21 12:06:23 2016
New Revision: 1725916

URL: http://svn.apache.org/viewvc?rev=1725916&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/branches/branch-1.8/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java

Modified: avro/branches/branch-1.8/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.8/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java?rev=1725916&r1=1725915&r2=1725916&view=diff
==============================================================================
--- avro/branches/branch-1.8/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java
(original)
+++ avro/branches/branch-1.8/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java
Thu Jan 21 12:06:23 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