This is an automated email from the ASF dual-hosted git repository.
magibney pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new 3643fca6fe2 SOLR-17349: (adjusted) SolrDocumentFetcher should always
skip lazy field loading overhead if documentCache==null (#2551)
3643fca6fe2 is described below
commit 3643fca6fe2468f1c2cc14f3514203a91f0783e2
Author: Michael Gibney <[email protected]>
AuthorDate: Tue Jul 9 10:23:27 2024 -0400
SOLR-17349: (adjusted) SolrDocumentFetcher should always skip lazy field
loading overhead if documentCache==null (#2551)
this also reverts the code change from
390c30ff56ad354a6ee55eaae54713dd8ec4cce3,
which is obviated by directly making `enableLazyFieldLoading` conditional
on presence of `documentCache`.
(cherry picked from commit 9a86b2102ef28f603a08fa7fdae153e7ae834960)
---
.../java/org/apache/solr/search/SolrDocumentFetcher.java | 16 ++++++----------
.../src/java/org/apache/solr/util/SolrPluginUtils.java | 2 +-
2 files changed, 7 insertions(+), 11 deletions(-)
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;
}