dsmiley commented on code in PR #1557:
URL: https://github.com/apache/solr/pull/1557#discussion_r1643483566


##########
solr/core/src/java/org/apache/solr/search/SolrDocumentFetcher.java:
##########
@@ -114,11 +114,33 @@ public class SolrDocumentFetcher {
 
   private final Set<String> largeFields;
 
-  private Collection<String> storedHighlightFieldNames; // lazy populated; use 
getter
+  private final Collection<String>[] storedHighlightFieldNames; // lazy 
populated; use getter
+
+  private final Collection<String>[] indexedFieldNames; // lazy populated; use 
getter
+
+  private final StoredFields storedFields;
+
+  private SolrDocumentFetcher(SolrDocumentFetcher template, StoredFields 
storedFields) {
+    this.searcher = template.searcher;
+    this.nLeaves = template.nLeaves;
+    this.enableLazyFieldLoading = template.enableLazyFieldLoading;
+    this.documentCache = template.documentCache;
+    this.nonStoredDVsUsedAsStored = template.nonStoredDVsUsedAsStored;
+    this.allNonStoredDVs = template.allNonStoredDVs;
+    this.nonStoredDVsWithoutCopyTargets = 
template.nonStoredDVsWithoutCopyTargets;
+    this.largeFields = template.largeFields;
+    this.dvsCanSubstituteStored = template.dvsCanSubstituteStored;
+    this.allStored = template.allStored;
+    this.storedHighlightFieldNames = template.indexedFieldNames;
+    this.indexedFieldNames = template.indexedFieldNames;
+    this.storedFields = storedFields;
+  }
 
-  private Collection<String> indexedFieldNames; // lazy populated; use getter
+  public SolrDocumentFetcher createInstance() throws IOException {

Review Comment:
   This is a weird method; and there's no javadoc.  A class that has a 
"createInstance" that returns a type of itself?  "clone" would be a better 
name.  Let's not make this public so people can't even easily call it; only 
SolrIndexSearcher should call it.



##########
solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java:
##########
@@ -427,7 +429,16 @@ public SolrIndexSearcher(
   }
 
   public SolrDocumentFetcher getDocFetcher() {
-    return docFetcher;
+    try {
+      return docFetcher.createInstance();
+    } catch (IOException e) {
+      // TODO: should we instead throw IOException?
+      throw new RuntimeIOException(e);
+    }
+  }
+
+  public <T> T interrogateDocFetcher(Function<SolrDocumentFetcher, T> func) {

Review Comment:
   Okay; this still feels awkward.  It's not about the docs... one could say 
the task of documenting it exposes its awkwardness.  I suppose 
SolrDocumentFetcher is doing too much now; probably need a separate abstraction 
to differentiate much of the stuff on this class from the actual fetching of 
docs.  We can leave for now but in Solr 10; ought to rethink this.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to