jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r748066 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene: MultiIndex.java SearchIndex.java
Date Thu, 26 Feb 2009 09:23:25 GMT
Author: mreutegg
Date: Thu Feb 26 09:23:25 2009
New Revision: 748066

URL: http://svn.apache.org/viewvc?rev=748066&view=rev
Log:
JCR-1998: Initialize hierarchy cache on startup

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java?rev=748066&r1=748065&r2=748066&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
Thu Feb 26 09:23:25 2009
@@ -277,8 +277,9 @@
         // init volatile index
         resetVolatileIndex();
 
-        // set index format version
-        CachingMultiIndexReader reader = getIndexReader();
+        // set index format version and at the same time
+        // initialize hierarchy cache if requested.
+        CachingMultiIndexReader reader = getIndexReader(handler.isInitializeHierarchyCache());
         try {
             version = IndexFormatVersion.getVersion(reader);
         } finally {
@@ -680,6 +681,21 @@
      * @throws IOException if an error occurs constructing the <code>IndexReader</code>.
      */
     public CachingMultiIndexReader getIndexReader() throws IOException {
+        return getIndexReader(false);
+    }
+
+    /**
+     * Returns an read-only <code>IndexReader</code> that spans alls indexes
of this
+     * <code>MultiIndex</code>.
+     *
+     * @param initCache when set <code>true</code> the hierarchy cache is
+     *                  completely initialized before this call returns.
+     *                  Otherwise the cache is initialized in a background
+     *                  thread.
+     * @return an <code>IndexReader</code>.
+     * @throws IOException if an error occurs constructing the <code>IndexReader</code>.
+     */
+    public CachingMultiIndexReader getIndexReader(boolean initCache) throws IOException {
         synchronized (updateMonitor) {
             if (multiReader != null) {
                 multiReader.acquire();
@@ -701,7 +717,7 @@
                 for (int i = 0; i < indexes.size(); i++) {
                     PersistentIndex pIdx = (PersistentIndex) indexes.get(i);
                     if (indexNames.contains(pIdx.getName())) {
-                        readerList.add(pIdx.getReadOnlyIndexReader());
+                        readerList.add(pIdx.getReadOnlyIndexReader(initCache));
                     }
                 }
                 readerList.add(volatileIndex.getReadOnlyIndexReader());

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java?rev=748066&r1=748065&r2=748066&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
Thu Feb 26 09:23:25 2009
@@ -434,6 +434,12 @@
     private SortComparatorSource scs;
 
     /**
+     * Flag that indicates whether the hierarchy cache should be initialized
+     * immediately on startup.
+     */
+    private boolean initializeHierarchyCache = true;
+
+    /**
      * Indicates if this <code>SearchIndex</code> is closed and cannot be used
      * anymore.
      */
@@ -2060,6 +2066,25 @@
         this.termInfosIndexDivisor = termInfosIndexDivisor;
     }
 
+    /**
+     * @return <code>true</code> if the hierarchy cache should be initialized
+     *         immediately on startup.
+     */
+    public boolean isInitializeHierarchyCache() {
+        return initializeHierarchyCache;
+    }
+
+    /**
+     * Whether the hierarchy cache should be initialized immediately on
+     * startup.
+     *
+     * @param initializeHierarchyCache <code>true</code> if the cache should
be
+     *                                 initialized immediately.
+     */
+    public void setInitializeHierarchyCache(boolean initializeHierarchyCache) {
+        this.initializeHierarchyCache = initializeHierarchyCache;
+    }
+
     //----------------------------< internal >----------------------------------
 
     /**



Mime
View raw message