lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r943931 - in /lucene/dev/trunk/lucene/src/java/org/apache/lucene: index/codecs/standard/StandardTermsDictReader.java util/DoubleBarrelLRUCache.java
Date Thu, 13 May 2010 16:41:34 GMT
Author: mikemccand
Date: Thu May 13 16:41:34 2010
New Revision: 943931

URL: http://svn.apache.org/viewvc?rev=943931&view=rev
Log:
LUCENE-2449: fix DBLRU cache to clone key when it promotes an entry during lookup

Modified:
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/DoubleBarrelLRUCache.java

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java?rev=943931&r1=943930&r2=943931&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java
(original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java
Thu May 13 16:41:34 2010
@@ -296,7 +296,7 @@ public class StandardTermsDictReader ext
         fieldTerm.term = term;
         TermState cachedState;
         if (useCache) {
-          cachedState = termsCache.get(new FieldAndTerm(fieldTerm));
+          cachedState = termsCache.get(fieldTerm);
           if (cachedState != null) {
             state.copy(cachedState);
             seekPending = true;

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/DoubleBarrelLRUCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/DoubleBarrelLRUCache.java?rev=943931&r1=943930&r2=943931&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/DoubleBarrelLRUCache.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/DoubleBarrelLRUCache.java Thu
May 13 16:41:34 2010
@@ -28,8 +28,9 @@ import java.util.Map;
  * <p>At any given time, one hash is primary and the other
  * is secondary.  {@link #get} first checks primary, and if
  * that's a miss, checks secondary.  If secondary has the
- * entry, it's promoted to primary.  Once primary is full,
- * the secondary is cleared and the two are swapped.</p>
+ * entry, it's promoted to primary (<b>NOTE</b>: the key is
+ * cloned at this point).  Once primary is full, the
+ * secondary is cleared and the two are swapped.</p>
  *
  * <p>This is not as space efficient as other possible
  * concurrent approaches (see LUCENE-2075): to achieve
@@ -41,7 +42,7 @@ import java.util.Map;
  * @lucene.internal
  */
 
-final public class DoubleBarrelLRUCache<K,V> {
+final public class DoubleBarrelLRUCache<K extends DoubleBarrelLRUCache.CloneableKey,V>
{
 
   public static abstract class CloneableKey {
     abstract public Object clone();
@@ -60,6 +61,7 @@ final public class DoubleBarrelLRUCache<
     cache2 = new ConcurrentHashMap<K,V>();
   }
 
+  @SuppressWarnings("unchecked") 
   public V get(K key) {
     final Map<K,V> primary;
     final Map<K,V> secondary;
@@ -78,7 +80,7 @@ final public class DoubleBarrelLRUCache<
       result = secondary.get(key);
       if (result != null) {
         // Promote to primary
-        put(key, result);
+        put((K) key.clone(), result);
       }
     }
     return result;



Mime
View raw message