You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2014/07/21 10:24:53 UTC

svn commit: r1612210 - in /lucene/dev/branches/branch_4x: ./ solr/ solr/CHANGES.txt solr/core/ solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java

Author: shalin
Date: Mon Jul 21 08:24:52 2014
New Revision: 1612210

URL: http://svn.apache.org/r1612210
Log:
SOLR-5968: BinaryResponseWriter fetches unnecessary stored fields when only pseudo-fields are requested

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java

Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1612210&r1=1612209&r2=1612210&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Mon Jul 21 08:24:52 2014
@@ -146,6 +146,9 @@ Optimizations
   DocumentBuilder.toDocument for use-cases with large number of fields and copyFields.
   (Steven Bower via shalin)
 
+* SOLR-5968: BinaryResponseWriter fetches unnecessary stored fields when only pseudo-fields
+  are requested. (Gregg Donovan via shalin)
+
 Other Changes
 ---------------------
 

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java?rev=1612210&r1=1612209&r2=1612210&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java Mon Jul 21 08:24:52 2014
@@ -34,6 +34,7 @@ import org.apache.solr.schema.*;
 import org.apache.solr.search.DocList;
 import org.apache.solr.search.ReturnFields;
 import org.apache.solr.search.SolrIndexSearcher;
+import org.apache.solr.search.SolrReturnFields;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -141,11 +142,19 @@ public class BinaryResponseWriter implem
       }
       
       Set<String> fnames = returnFields.getLuceneFieldNames();
+      boolean onlyPseudoFields = (fnames == null && !returnFields.wantsAllFields())
+          || (fnames != null && fnames.size() == 1 && SolrReturnFields.SCORE.equals(fnames.iterator().next()));
       context.iterator = ids.iterator();
       for (int i = 0; i < sz; i++) {
         int id = context.iterator.nextDoc();
-        Document doc = searcher.doc(id, fnames);
-        SolrDocument sdoc = getDoc(doc);
+        SolrDocument sdoc;
+        if (onlyPseudoFields) {
+          // no need to get stored fields of the document, see SOLR-5968
+          sdoc = new SolrDocument();
+        } else {
+          Document doc = searcher.doc(id, fnames);
+          sdoc = getDoc(doc);
+        }
         if( transformer != null ) {
           transformer.transform(sdoc, id);
         }
@@ -178,9 +187,9 @@ public class BinaryResponseWriter implem
       SolrDocument solrDoc = new SolrDocument();
       for (IndexableField f : doc) {
         String fieldName = f.name();
-        if( !returnFields.wantsField(fieldName) ) 
+        if( !returnFields.wantsField(fieldName) )
           continue;
-        
+
         SchemaField sf = schema.getFieldOrNull(fieldName);
         Object val = null;
         try {