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:09:27 UTC
svn commit: r1518936 -
/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java
Author: mikemccand
Date: Fri Aug 30 11:09:27 2013
New Revision: 1518936
URL: http://svn.apache.org/r1518936
Log:
LUCENE-5192: use syn'd method to set field's DV type
Modified:
lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java?rev=1518936&r1=1518935&r2=1518936&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java Fri Aug 30 11:09:27 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) {