jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r602855 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene: CachingIndexReader.java CachingMultiIndexReader.java DocNumberCache.java
Date Mon, 10 Dec 2007 10:46:11 GMT
Author: mreutegg
Date: Mon Dec 10 02:46:05 2007
New Revision: 602855

URL: http://svn.apache.org/viewvc?rev=602855&view=rev
Log:
JCR-1266: Use creation tick instead of weak references in DocNumberCache

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingMultiIndexReader.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DocNumberCache.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java?rev=602855&r1=602854&r2=602855&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java
Mon Dec 10 02:46:05 2007
@@ -176,7 +176,7 @@
                     // to a newer one. the cache will still contain a cache
                     // entry from the old until it is overwritten by the
                     // newer index.
-                    if (e.reader == this && !isDeleted(e.doc)) {
+                    if (e.creationTick == creationTick && !isDeleted(e.doc)) {
                         return new SingleTermDocs(e.doc);
                     }
                 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingMultiIndexReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingMultiIndexReader.java?rev=602855&r1=602854&r2=602855&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingMultiIndexReader.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingMultiIndexReader.java
Mon Dec 10 02:46:05 2007
@@ -24,7 +24,6 @@
 
 import java.io.IOException;
 import java.util.Map;
-import java.util.IdentityHashMap;
 import java.util.HashMap;
 
 /**
@@ -41,11 +40,6 @@
     private ReadOnlyIndexReader[] subReaders;
 
     /**
-     * Map of OffsetReaders, identified by caching reader they are based on.
-     */
-    private final Map readersByBase = new IdentityHashMap();
-
-    /**
      * Map of {@link OffsetReader}s, identified by creation tick.
      */
     private final Map readersByCreationTick = new HashMap();
@@ -85,7 +79,6 @@
             starts[i] = maxDoc;
             maxDoc += subReaders[i].maxDoc();
             OffsetReader offsetReader = new OffsetReader(subReaders[i], starts[i]);
-            readersByBase.put(subReaders[i].getBase().getBase(), offsetReader);
             readersByCreationTick.put(new Long(subReaders[i].getCreationTick()), offsetReader);
         }
         starts[subReaders.length] = maxDoc;
@@ -131,7 +124,8 @@
                 // check if valid:
                 // 1) reader must be in the set of readers
                 // 2) doc must not be deleted
-                OffsetReader offsetReader = (OffsetReader) readersByBase.get(e.reader);
+                OffsetReader offsetReader = (OffsetReader) readersByCreationTick.get(
+                        new Long(e.creationTick));
                 if (offsetReader != null && !offsetReader.reader.isDeleted(e.doc))
{
                     return new SingleTermDocs(e.doc + offsetReader.offset);
                 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DocNumberCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DocNumberCache.java?rev=602855&r1=602854&r2=602855&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DocNumberCache.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DocNumberCache.java
Mon Dec 10 02:46:05 2007
@@ -98,17 +98,17 @@
             if (e != null) {
                 // existing entry
                 // ignore if reader is older than the one in entry
-                if (reader.getCreationTick() <= e.reader.getCreationTick()) {
+                if (reader.getCreationTick() <= e.creationTick) {
                     if (log.isDebugEnabled()) {
                         log.debug("Ignoring put(). New entry is not from a newer reader.
"
-                                + "existing: " + e.reader.getCreationTick()
+                                + "existing: " + e.creationTick
                                 + ", new: " + reader.getCreationTick());
                     }
                     e = null;
                 }
             } else {
                 // entry did not exist
-                e = new Entry(reader, n);
+                e = new Entry(reader.getCreationTick(), n);
             }
 
             if (e != null) {
@@ -174,17 +174,17 @@
     public static final class Entry {
 
         /**
-         * The IndexReader.
+         * The creation tick of the IndexReader.
          */
-        final CachingIndexReader reader;
+        final long creationTick;
 
         /**
          * The document number.
          */
         final int doc;
 
-        Entry(CachingIndexReader reader, int doc) {
-            this.reader = reader;
+        Entry(long creationTick, int doc) {
+            this.creationTick = creationTick;
             this.doc = doc;
         }
     }



Mime
View raw message