jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1142919 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
Date Tue, 05 Jul 2011 08:21:10 GMT
Author: alexparvulescu
Date: Tue Jul  5 08:21:10 2011
New Revision: 1142919

URL: http://svn.apache.org/viewvc?rev=1142919&view=rev
Log:
JCR-2918 Avoid unnecessary index reader calls when using aggregate definitions

Modified:
    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/SearchIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java?rev=1142919&r1=1142918&r2=1142919&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
Tue Jul  5 08:21:10 2011
@@ -1619,45 +1619,46 @@ public class SearchIndex extends Abstrac
      */
     protected void retrieveAggregateRoot(
             Set<NodeId> removedIds, Map<NodeId, NodeState> map) {
-        if (indexingConfig != null) {
-            AggregateRule[] aggregateRules = indexingConfig.getAggregateRules();
-            if (aggregateRules == null) {
-                return;
-            }
-            int found = 0;
-            long time = System.currentTimeMillis();
+        if(removedIds.isEmpty() || indexingConfig == null){
+            return;
+        }
+        AggregateRule[] aggregateRules = indexingConfig.getAggregateRules();
+        if (aggregateRules == null) {
+            return;
+        }
+        int found = 0;
+        long time = System.currentTimeMillis();
+        try {
+            CachingMultiIndexReader reader = index.getIndexReader();
             try {
-                CachingMultiIndexReader reader = index.getIndexReader();
+                Term aggregateIds =
+                    new Term(FieldNames.AGGREGATED_NODE_UUID, "");
+                TermDocs tDocs = reader.termDocs();
                 try {
-                    Term aggregateIds =
-                        new Term(FieldNames.AGGREGATED_NODE_UUID, "");
-                    TermDocs tDocs = reader.termDocs();
-                    try {
-                        ItemStateManager ism = getContext().getItemStateManager();
-                        for (NodeId id : removedIds) {
-                            aggregateIds =
-                                aggregateIds.createTerm(id.toString());
-                            tDocs.seek(aggregateIds);
-                            while (tDocs.next()) {
-                                Document doc = reader.document(
-                                        tDocs.doc(), FieldSelectors.UUID);
-                                NodeId nId = new NodeId(doc.get(FieldNames.UUID));
-                                map.put(nId, (NodeState) ism.getItemState(nId));
-                                found++;
-                            }
+                    ItemStateManager ism = getContext().getItemStateManager();
+                    for (NodeId id : removedIds) {
+                        aggregateIds =
+                            aggregateIds.createTerm(id.toString());
+                        tDocs.seek(aggregateIds);
+                        while (tDocs.next()) {
+                            Document doc = reader.document(
+                                    tDocs.doc(), FieldSelectors.UUID);
+                            NodeId nId = new NodeId(doc.get(FieldNames.UUID));
+                            map.put(nId, (NodeState) ism.getItemState(nId));
+                            found++;
                         }
-                    } finally {
-                        tDocs.close();
                     }
                 } finally {
-                    reader.release();
+                    tDocs.close();
                 }
-            } catch (Exception e) {
-                log.warn("Exception while retrieving aggregate roots", e);
+            } finally {
+                reader.release();
             }
-            time = System.currentTimeMillis() - time;
-            log.debug("Retrieved {} aggregate roots in {} ms.", found, time);
+        } catch (Exception e) {
+            log.warn("Exception while retrieving aggregate roots", e);
         }
+        time = System.currentTimeMillis() - time;
+        log.debug("Retrieved {} aggregate roots in {} ms.", found, time);
     }
 
     //----------------------------< internal >----------------------------------



Mime
View raw message