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


##########
solr/core/src/java/org/apache/solr/response/DocsStreamer.java:
##########
@@ -186,6 +187,57 @@ public static SolrDocument convertLuceneDocToSolrDoc(
   public void remove() { // do nothing
   }
 
+  /**
+   * Replace Lucene {@link IndexableField} values on a {@link SolrDocument} 
(and nested / child
+   * documents) with the SolrJ-native objects that clients see after JavaBin 
deserialization. Used
+   * by JavaBin response writing generally, including the EmbeddedSolrServer 
streaming path, so
+   * {@code queryAndStreamResponse} matches {@code query} / {@code 
HttpSolrClient}.
+   *
+   * <p>Do not call this from {@link #convertLuceneDocToSolrDoc}; JSON/XML 
writers and some
+   * transformers still expect stored fields as {@link IndexableField}.
+   *
+   * @see #getValue(SchemaField, IndexableField)
+   */
+  public static SolrDocument externalizeStoredValues(SolrDocument doc, 
IndexSchema schema) {
+    if (doc == null || schema == null) {
+      return doc;
+    }
+    for (String name : new ArrayList<>(doc.getFieldNames())) {

Review Comment:
   is this defensive copy actually needed?  the doc.setField replaces the value 
side so the hash table should stay intact.  Even better, SolrDocument is an 
Iterable over Entry, which is better because you can just call setValue on the 
entry.  Overall, more efficient.



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