You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2013/08/30 13:13:47 UTC

svn commit: r1518937 - in /lucene/dev/branches/branch_4x: ./ lucene/ lucene/core/ lucene/core/src/java/org/apache/lucene/index/FieldInfos.java

Author: mikemccand
Date: Fri Aug 30 11:13:46 2013
New Revision: 1518937

URL: http://svn.apache.org/r1518937
Log:
LUCENE-5192: use syn'd method to set field's DV type

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/lucene/   (props changed)
    lucene/dev/branches/branch_4x/lucene/core/   (props changed)
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java?rev=1518937&r1=1518936&r2=1518937&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java Fri Aug 30 11:13:46 2013
@@ -228,6 +228,11 @@ public class FieldInfos implements Itera
       nameToNumber.clear();
       docValuesType.clear();
     }
+
+    synchronized void setDocValuesType(int number, String name, DocValuesType dvType) {
+      assert containsConsistent(number, name, dvType);
+      docValuesType.put(name, dvType);
+    }
   }
   
   static final class Builder {
@@ -287,9 +292,14 @@ public class FieldInfos implements Itera
         fi.update(isIndexed, storeTermVector, omitNorms, storePayloads, indexOptions);
 
         if (docValues != null) {
-          fi.setDocValuesType(docValues);
-          // must also update docValuesType map so it's aware of this field's DocValueType 
-          globalFieldNumbers.docValuesType.put(name, docValues);
+          // only pay the synchronization cost if fi does not already have a DVType
+          boolean updateGlobal = !fi.hasDocValues();
+          fi.setDocValuesType(docValues); // this will also perform the consistency check.
+          if (updateGlobal) {
+            // must also update docValuesType map so it's
+            // aware of this field's DocValueType 
+            globalFieldNumbers.setDocValuesType(fi.number, name, docValues);
+          }
         }
 
         if (!fi.omitsNorms() && normType != null) {