nick-boss-tech commented on code in PR #4965:
URL: https://github.com/apache/solr/pull/4965#discussion_r4141195354
##########
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:
🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
You're right on both counts. I verified against SolrDocument: `setField` on
an existing key is a value-only `put` (no structural change to the map), and I
surveyed every `FieldType.toObject` return type reachable here
(String/Number/Boolean/Date/byte[]/List) — none of them hits `setField`'s
Object[]/Iterable normalization, so `entry.setValue` is behaviorally identical.
Switched to iterating the document's entries directly:
`entry.setValue(converted)` for conversions, `iterator.remove()` for fields
whose stored value failed to convert. No defensive copy, and no per-field hash
lookup. Focused tests (`TestJavaBinResponseWriter`,
`TestEmbeddedSolrServerStreamingTypes`) pass; pushed as `0d1f7c1191d`.
--
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]