MCPcopy Create free account
hub / github.com/apache/solr / DocsStreamer

Class DocsStreamer

solr/core/src/java/org/apache/solr/response/DocsStreamer.java:59–257  ·  view source on GitHub ↗

This streams SolrDocuments from a DocList and applies transformer

Source from the content-addressed store, hash-verified

57
58/** This streams SolrDocuments from a DocList and applies transformer */
59public class DocsStreamer implements Iterator<SolrDocument> {
60 /**
61 * A hardcoded list of known Solr field types that will be trusted to control their own conversion
62 * of stored field values into external Objects (via {@link FieldType#toObject}) when returning
63 * {@link SolrDocument} instances to clients.
64 *
65 * <p>For historic reasons, this Set is consulted using an <em>equality</em> basis, so subclasses
66 * of these "known" types are not given the same level of trust.
67 *
68 * <p>Any field type not found in this list will have stored values externalized as
69 * <em>Strings</em> using {@link FieldType#toExternal} unless they implement {@link
70 * ExternalizeStoredValuesAsObjects}
71 *
72 * @deprecated new field types should not be added to this list, instead use {@link
73 * ExternalizeStoredValuesAsObjects}
74 */
75 @Deprecated(since = "10.1")
76 public static final Set<Class<? extends FieldType>> KNOWN_TYPES = new HashSet<>();
77
78 private final ResultContext rctx;
79 private final SolrDocumentFetcher docFetcher; // a collaborator of SolrIndexSearcher
80 private final DocList docs;
81
82 private final DocTransformer transformer;
83 private final DocIterator docIterator;
84
85 private final SolrReturnFields solrReturnFields;
86
87 private int idx = -1;
88
89 public DocsStreamer(ResultContext rctx) {
90 this.rctx = rctx;
91 this.docs = rctx.getDocList();
92 transformer = rctx.getReturnFields().getTransformer();
93 docIterator = this.docs.iterator();
94 docFetcher = rctx.getDocFetcher();
95 solrReturnFields = (SolrReturnFields) rctx.getReturnFields();
96
97 if (transformer != null) {
98 transformer.setContext(rctx);
99 }
100 }
101
102 public int currentIndex() {
103 return idx;
104 }
105
106 @Override
107 public boolean hasNext() {
108 return docIterator.hasNext();
109 }
110
111 @Override
112 public SolrDocument next() {
113 int id = docIterator.nextDoc();
114 idx++;
115 SolrDocument sdoc = docFetcher.solrDoc(id, solrReturnFields);
116

Callers

nothing calls this directly

Calls 1

addMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…