jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1559840 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/ oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/l...
Date Mon, 20 Jan 2014 22:08:31 GMT
Author: jukka
Date: Mon Jan 20 22:08:30 2014
New Revision: 1559840

URL: http://svn.apache.org/r1559840
Log:
OAK-1292: Avoid async indexer commits when there are no changes to index

Make the callback argument @Nonnull to avoid repeated null checks

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexEditorProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexEditor.java
    jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorContext.java
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditor.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexEditorProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexEditorProvider.java?rev=1559840&r1=1559839&r2=1559840&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexEditorProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexEditorProvider.java
Mon Jan 20 22:08:30 2014
@@ -51,5 +51,5 @@ public interface IndexEditorProvider {
     Editor getIndexEditor(
             @Nonnull String type, @Nonnull NodeBuilder definition,
             @Nonnull NodeState root, 
-            @CheckForNull IndexUpdateCallback callback) throws CommitFailedException;
+            @Nonnull IndexUpdateCallback callback) throws CommitFailedException;
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java?rev=1559840&r1=1559839&r2=1559840&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java
Mon Jan 20 22:08:30 2014
@@ -62,7 +62,7 @@ class IndexUpdate implements Editor {
     private final List<Editor> reindex = newArrayList();
 
     /**
-     * Callback for the 'before' events of the indexing job
+     * Callback for the update events of the indexing job
      */
     private final IndexUpdateCallback updateCallback;
 
@@ -74,7 +74,7 @@ class IndexUpdate implements Editor {
         this.async = async;
         this.root = checkNotNull(root);
         this.builder = checkNotNull(builder);
-        this.updateCallback = updateCallback;
+        this.updateCallback = checkNotNull(updateCallback);
     }
 
     private IndexUpdate(IndexUpdate parent, String name) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateProvider.java?rev=1559840&r1=1559839&r2=1559840&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateProvider.java
Mon Jan 20 22:08:30 2014
@@ -26,6 +26,14 @@ import org.apache.jackrabbit.oak.spi.sta
 
 public class IndexUpdateProvider implements EditorProvider {
 
+    private static final IndexUpdateCallback NOOP_CALLBACK =
+            new IndexUpdateCallback() {
+                @Override
+                public void indexUpdate() {
+                    // do nothing
+                }
+            };
+
     private final IndexEditorProvider provider;
 
     private final String async;
@@ -43,7 +51,7 @@ public class IndexUpdateProvider impleme
     @Override @CheckForNull
     public Editor getRootEditor(
             NodeState before, NodeState after, NodeBuilder builder) {
-        return new IndexUpdate(provider, async, after, builder, null);
+        return new IndexUpdate(provider, async, after, builder, NOOP_CALLBACK);
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexEditor.java?rev=1559840&r1=1559839&r2=1559840&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexEditor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexEditor.java
Mon Jan 20 22:08:30 2014
@@ -241,9 +241,7 @@ class PropertyIndexEditor implements Ind
             }
 
             if (!beforeKeys.isEmpty() || !afterKeys.isEmpty()) {
-                if (updateCallback != null) {
-                    updateCallback.indexUpdate();
-                }
+                updateCallback.indexUpdate();
                 NodeBuilder index = definition.child(INDEX_CONTENT_NODE_NAME);
                 getStrategy(keysToCheckForUniqueness != null).update(
                         index, getPath(), beforeKeys, afterKeys);

Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorContext.java?rev=1559840&r1=1559839&r2=1559840&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorContext.java
(original)
+++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorContext.java
Mon Jan 20 22:08:30 2014
@@ -172,9 +172,7 @@ public class LuceneIndexEditorContext {
     }
 
     void indexUpdate() throws CommitFailedException {
-        if (this.updateCallback != null) {
-            updateCallback.indexUpdate();
-        }
+        updateCallback.indexUpdate();
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditor.java?rev=1559840&r1=1559839&r2=1559840&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditor.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditor.java
Mon Jan 20 22:08:30 2014
@@ -58,7 +58,7 @@ public class SolrIndexEditor implements 
 
     private boolean propertiesChanged = false;
 
-    private IndexUpdateCallback updateCallback;
+    private final IndexUpdateCallback updateCallback;
 
     SolrIndexEditor(
             NodeBuilder definition, SolrServer solrServer,
@@ -98,7 +98,7 @@ public class SolrIndexEditor implements 
     public void leave(NodeState before, NodeState after)
             throws CommitFailedException {
         if (propertiesChanged || !before.exists()) {
-            indexUpdate();
+            updateCallback.indexUpdate();
             try {
                 solrServer.add(docFromState(after));
             } catch (SolrServerException e) {
@@ -159,7 +159,7 @@ public class SolrIndexEditor implements 
         try {
             solrServer.deleteByQuery(String.format(
                     "%s:%s\\/*", configuration.getPathField(), path));
-            indexUpdate();
+            updateCallback.indexUpdate();
         } catch (SolrServerException e) {
             throw new CommitFailedException(
                     "Solr", 5, "Failed to remove documents from Solr", e);
@@ -199,10 +199,4 @@ public class SolrIndexEditor implements 
         return inputDocument;
     }
 
-    protected void indexUpdate() throws CommitFailedException {
-        if (updateCallback != null) {
-            updateCallback.indexUpdate();
-        }
-    }
-
 }



Mime
View raw message