SOLR-6252: A couple of small improvements to UnInvertedField class.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1612422 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2014-07-21 22:29:31 +00:00
parent 61967d99a4
commit 514e04fe7f
2 changed files with 11 additions and 6 deletions

View File

@ -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 Components

View File

@ -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();