You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by is...@apache.org on 2016/12/14 18:13:14 UTC

lucene-solr:jira/solr-5944: Fixing previously dropped nocommits

Repository: lucene-solr
Updated Branches:
  refs/heads/jira/solr-5944 d36e0f530 -> 6642fd7e1


Fixing previously dropped nocommits


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/6642fd7e
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/6642fd7e
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/6642fd7e

Branch: refs/heads/jira/solr-5944
Commit: 6642fd7e13da940214f4630bbf876ae97fcd7641
Parents: d36e0f5
Author: Ishan Chattopadhyaya <ic...@gmail.com>
Authored: Thu Dec 15 01:12:55 2016 +0700
Committer: Ishan Chattopadhyaya <ic...@gmail.com>
Committed: Thu Dec 15 01:12:55 2016 +0700

----------------------------------------------------------------------
 .../processor/AtomicUpdateDocumentMerger.java   | 20 ++++++++--------
 .../update/TestInPlaceUpdatesStandalone.java    | 24 ++++++++++----------
 2 files changed, 21 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6642fd7e/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateDocumentMerger.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateDocumentMerger.java b/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateDocumentMerger.java
index b558d86..de67593 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateDocumentMerger.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateDocumentMerger.java
@@ -186,8 +186,16 @@ public class AtomicUpdateDocumentMerger {
       return Collections.emptySet();
     }
 
-    // lazy init this so we don't call iw.getFields() (and sync lock on IndexWriter) unless needed
     Set<String> fieldNamesFromIndexWriter = null;
+    SolrCore core = cmd.getReq().getCore();
+    RefCounted<IndexWriter> holder = core.getSolrCoreState().getIndexWriter(core);
+    try {
+      IndexWriter iw = holder.get();
+      fieldNamesFromIndexWriter = iw.getFieldNames();
+    } finally {
+      holder.decref();
+    }
+
     // second pass over the candidates for in-place updates
     // this time more expensive checks
     for (String fieldName: candidateFields) {
@@ -203,16 +211,6 @@ public class AtomicUpdateDocumentMerger {
           return Collections.emptySet();
       }
 
-      if (null == fieldNamesFromIndexWriter) { // lazy init fieldNamesFromIndexWriter
-        SolrCore core = cmd.getReq().getCore();
-        RefCounted<IndexWriter> holder = core.getSolrCoreState().getIndexWriter(core);
-        try {
-          IndexWriter iw = holder.get();
-          fieldNamesFromIndexWriter = iw.getFieldNames();
-        } finally {
-          holder.decref();
-        }
-      }
       if (! fieldNamesFromIndexWriter.contains(fieldName) ) {
         return Collections.emptySet(); // if this field doesn't exist, DV update can't work
       }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6642fd7e/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java
index a154d11..007d959 100644
--- a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java
+++ b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java
@@ -977,7 +977,7 @@ public class TestInPlaceUpdatesStandalone extends TestRTGBase {
   }
 
   /** 
-   * @see #callIsInPlaceUpdate
+   * @see #callComputeInPlaceUpdateableFields
    * @see AtomicUpdateDocumentMerger#computeInPlaceUpdateableFields 
    */
   @Test
@@ -985,35 +985,35 @@ public class TestInPlaceUpdatesStandalone extends TestRTGBase {
     Set<String> inPlaceUpdatedFields = new HashSet<String>();
 
     // In-place updateable field updated before it exists SHOULD NOT BE in-place updated:
-    inPlaceUpdatedFields = callIsInPlaceUpdate(sdoc("id", "1", "_version_", 42L,
+    inPlaceUpdatedFields = callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L,
                                                     "inplace_updatable_float", map("set", 10)));
     assertFalse(inPlaceUpdatedFields.contains("inplace_updatable_float"));
 
     // In-place updateable field updated after it exists SHOULD BE in-place updated:
     addAndGetVersion(sdoc("id", "1", "inplace_updatable_float", "0"), params()); // setting up the dv
-    inPlaceUpdatedFields = callIsInPlaceUpdate(sdoc("id", "1", "_version_", 42L,
+    inPlaceUpdatedFields = callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L,
                                                     "inplace_updatable_float", map("set", 10)));
     assertTrue(inPlaceUpdatedFields.contains("inplace_updatable_float"));
 
-    inPlaceUpdatedFields = callIsInPlaceUpdate(sdoc("id", "1", "_version_", 42L,
+    inPlaceUpdatedFields = callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L,
                                                     "inplace_updatable_float", map("inc", 10)));
     assertTrue(inPlaceUpdatedFields.contains("inplace_updatable_float"));
     
-    inPlaceUpdatedFields = callIsInPlaceUpdate(sdoc("id", "1", "_version_", 42L,
+    inPlaceUpdatedFields = callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L,
                                                     "inplace_updatable_int", map("set", 10)));
     assertTrue(inPlaceUpdatedFields.contains("inplace_updatable_int"));
     
     // Non in-place updates
     addAndGetVersion(sdoc("id", "1", "stored_i", "0"), params()); // setting up the dv
     assertTrue("stored field updated",
-               callIsInPlaceUpdate(sdoc("id", "1", "_version_", 42L, "stored_i", map("inc", 1))).isEmpty());
+               callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L, "stored_i", map("inc", 1))).isEmpty());
     
     assertTrue("No map means full document update",
-               callIsInPlaceUpdate(sdoc("id", "1", "_version_", 42L,
+               callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L,
                                         "inplace_updatable_int", "100")).isEmpty());
   
     assertTrue("non existent dynamic dv field updated first time",
-               callIsInPlaceUpdate(sdoc("id", "1", "_version_", 42L,
+               callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L,
                                         "new_updateable_int_i_dvo", map("set", 10))).isEmpty());
     
     // After adding a full document with the dynamic dv field, in-place update should work
@@ -1021,17 +1021,17 @@ public class TestInPlaceUpdatesStandalone extends TestRTGBase {
     if (random().nextBoolean()) {
       assertU(commit("softCommit", "false"));
     }
-    inPlaceUpdatedFields = callIsInPlaceUpdate(sdoc("id", "2", "_version_", 42L,
+    inPlaceUpdatedFields = callComputeInPlaceUpdateableFields(sdoc("id", "2", "_version_", 42L,
                                                     "new_updateable_int_i_dvo", map("set", 10)));
     assertTrue(inPlaceUpdatedFields.contains("new_updateable_int_i_dvo"));
 
     // If a supported dv field has a copyField target which is supported, it should be an in-place update
-    inPlaceUpdatedFields = callIsInPlaceUpdate(sdoc("id", "1", "_version_", 42L,
+    inPlaceUpdatedFields = callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L,
                                                     "copyfield1_src__both_updateable", map("set", 10)));
     assertTrue(inPlaceUpdatedFields.contains("copyfield1_src__both_updateable"));
 
     // If a supported dv field has a copyField target which is not supported, it should not be an in-place update
-    inPlaceUpdatedFields = callIsInPlaceUpdate(sdoc("id", "1", "_version_", 42L,
+    inPlaceUpdatedFields = callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L,
                                                     "copyfield2_src__only_src_updatable", map("set", 10)));
     assertTrue(inPlaceUpdatedFields.isEmpty());
   }
@@ -1087,7 +1087,7 @@ public class TestInPlaceUpdatesStandalone extends TestRTGBase {
    * Helper method that sets up a req/cmd to run {@link AtomicUpdateDocumentMerger#computeInPlaceUpdateableFields} 
    * on the specified solr input document.
    */
-  private static Set<String> callIsInPlaceUpdate(final SolrInputDocument sdoc) throws Exception {
+  private static Set<String> callComputeInPlaceUpdateableFields(final SolrInputDocument sdoc) throws Exception {
     try (SolrQueryRequest req = req()) {
       AddUpdateCommand cmd = new AddUpdateCommand(req);
       cmd.solrDoc = sdoc;