Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-17349: (adjusted) SolrDocumentFetcher should always skip lazy field loading overhead if documentCache==null (#2551)

Michael Gibney9a86b2102ef2
diff --git a/solr/core/src/java/org/apache/solr/search/SolrDocumentFetcher.java b/solr/core/src/java/org/apache/solr/search/SolrDocumentFetcher.java
index 4526d437a6e..ed0ab9e1466 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrDocumentFetcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrDocumentFetcher.java
@@ -150,7 +150,6 @@ public class SolrDocumentFetcher {
SolrDocumentFetcher(SolrIndexSearcher searcher, SolrConfig solrConfig, boolean cachingEnabled) {
this.searcher = searcher;
this.nLeaves = searcher.getTopReaderContext().leaves().size();
- this.enableLazyFieldLoading = solrConfig.enableLazyFieldLoading;
if (cachingEnabled) {
documentCache =
solrConfig.documentCacheConfig == null
@@ -160,6 +159,9 @@ public class SolrDocumentFetcher {
documentCache = null;
}
+ // lazy loading makes no sense if we don't have a `documentCache`
+ this.enableLazyFieldLoading = solrConfig.enableLazyFieldLoading && documentCache != null;
+
final Set<String> nonStoredDVsUsedAsStored = new HashSet<>();
final Set<String> allNonStoredDVs = new HashSet<>();
final Set<String> nonStoredDVsWithoutCopyTargets = new HashSet<>();
@@ -359,15 +361,9 @@ public class SolrDocumentFetcher {
super(toLoad);
this.docId = docId;
this.doc = getDocument();
- if (documentCache == null) {
- // lazy loading makes no sense if we don't have a `documentCache`
- this.lazyFieldProducer = null;
- this.addLargeFieldsLazily = false;
- } else {
- this.lazyFieldProducer =
- toLoad != null && enableLazyFieldLoading ? new LazyDocument(reader, docId) : null;
- this.addLargeFieldsLazily = !largeFields.isEmpty();
- }
+ this.lazyFieldProducer =
+ toLoad != null && enableLazyFieldLoading ? new LazyDocument(reader, docId) : null;
+ this.addLargeFieldsLazily = (documentCache != null && !largeFields.isEmpty());
// TODO can we return Status.STOP after a val is loaded and we know there are no other fields
// of interest?
// When: toLoad is one single-valued field, no lazyFieldProducer
diff --git a/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java b/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
index 495e05da101..44ade037f0e 100644
--- a/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
+++ b/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
@@ -225,7 +225,7 @@ public class SolrPluginUtils {
ResponseBuilder rb, DocList docs, Query query, SolrQueryRequest req, SolrQueryResponse res)
throws IOException {
SolrIndexSearcher searcher = req.getSearcher();
- if (!searcher.getDocFetcher().isLazyFieldLoadingEnabled()) {
+ if (!searcher.interrogateDocFetcher(SolrDocumentFetcher::isLazyFieldLoadingEnabled)) {
// nothing to do
return;
}