Apache Solr open-source search software
SOLR-6252: A couple of small improvements to UnInvertedField class.
Mark Robert Miller514e04fe7f96
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex e69d9aea1d0..b4853c75819 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -272,6 +272,9 @@ Other Changes* SOLR-3893: DIH should not depend on mail.jar,activation.jar (Timothy Potter, Steve Rowe)+* SOLR-6252: A couple of small improvements to UnInvertedField class.+ (Vamsee Yarlagadda, Gregory Chanan, Mark Miller)+================== 4.9.0 ==================Versions of Major Componentsdiff --git a/solr/core/src/java/org/apache/solr/request/UnInvertedField.java b/solr/core/src/java/org/apache/solr/request/UnInvertedField.javaindex 6424f00fa23..9f9e9f0bb05 100644--- a/solr/core/src/java/org/apache/solr/request/UnInvertedField.java+++ b/solr/core/src/java/org/apache/solr/request/UnInvertedField.java@@ -104,13 +104,11 @@ public class UnInvertedField extends DocTermOrds {private SolrIndexSearcher.DocsEnumState deState;private final SolrIndexSearcher searcher;- private final boolean isPlaceholder;private static UnInvertedField uifPlaceholder = new UnInvertedField();private UnInvertedField() { // Dummy for synchronization.super("fake", 0, 0); // cheapest initialization I can find.- isPlaceholder = true;searcher = null;}@@ -183,7 +181,6 @@ public class UnInvertedField extends DocTermOrds {DEFAULT_INDEX_INTERVAL_BITS);//System.out.println("maxTermDocFreq=" + maxTermDocFreq + " maxDoc=" + searcher.maxDoc());- isPlaceholder = false;final String prefix = TrieField.getMainValuePrefix(searcher.getSchema().getFieldType(field));this.searcher = searcher;try {@@ -674,9 +671,14 @@ public class UnInvertedField extends DocTermOrds {synchronized (cache) {uif = cache.get(field);if (uif == null) {- cache.put(field, uifPlaceholder); // This thread will load this field, don't let other threads try.+ /**+ * We use this place holder object to pull the UninvertedField construction out of the sync+ * so that if many fields are accessed in a short time, the UninvertedField can be+ * built for these fields in parallel rather than sequentially.+ */+ cache.put(field, uifPlaceholder);} else {- if (uif.isPlaceholder == false) {+ if (uif != uifPlaceholder) {return uif;}doWait = true; // Someone else has put the place holder in, wait for that to complete.@@ -686,7 +688,7 @@ public class UnInvertedField extends DocTermOrds {try {synchronized (cache) {uif = cache.get(field); // Should at least return the placeholder, NPE if not is OK.- if (uif.isPlaceholder == false) { // OK, another thread put this in the cache we should be good.+ if (uif != uifPlaceholder) { // OK, another thread put this in the cache we should be good.return uif;}cache.wait();