You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cp...@apache.org on 2016/09/26 13:29:09 UTC

[3/3] lucene-solr:master: SOLR-9543: reduce code duplication in ReRankQParserPlugin.ReRankCollector.topDocs (part 2 of 2)

SOLR-9543: reduce code duplication in ReRankQParserPlugin.ReRankCollector.topDocs (part 2 of 2)


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/a8f4ef02
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/a8f4ef02
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/a8f4ef02

Branch: refs/heads/master
Commit: a8f4ef02edf83043fcf04db2a8c42832892aaa78
Parents: be4233c
Author: Christine Poerschke <cp...@apache.org>
Authored: Mon Sep 26 12:27:12 2016 +0100
Committer: Christine Poerschke <cp...@apache.org>
Committed: Mon Sep 26 13:38:26 2016 +0100

----------------------------------------------------------------------
 .../apache/solr/search/ReRankQParserPlugin.java | 52 ++++++--------------
 1 file changed, 15 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a8f4ef02/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
index e4f00ee..a230170 100644
--- a/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
@@ -268,45 +268,23 @@ public class ReRankQParserPlugin extends QParserPlugin {
           IntIntHashMap boostedDocs = QueryElevationComponent.getBoostDocs((SolrIndexSearcher)searcher, boostedPriority, requestContext);
 
           Arrays.sort(rescoredDocs.scoreDocs, new BoostedComp(boostedDocs, mainDocs.scoreDocs, rescoredDocs.getMaxScore()));
+        }
 
-          if(howMany == rescoredDocs.scoreDocs.length) {
-            return rescoredDocs; // Just return the rescoredDocs
-          } else if(howMany > rescoredDocs.scoreDocs.length) {
-            //We need to return more then we've reRanked, so create the combined page.
-            ScoreDoc[] scoreDocs = new ScoreDoc[howMany];
-            System.arraycopy(mainScoreDocs, 0, scoreDocs, 0, scoreDocs.length); //lay down the initial docs
-            System.arraycopy(rescoredDocs.scoreDocs, 0, scoreDocs, 0, rescoredDocs.scoreDocs.length);//overlay the re-ranked docs.
-            rescoredDocs.scoreDocs = scoreDocs;
-            return rescoredDocs;
-          } else {
-            //We've rescored more then we need to return.
-            ScoreDoc[] scoreDocs = new ScoreDoc[howMany];
-            System.arraycopy(rescoredDocs.scoreDocs, 0, scoreDocs, 0, howMany);
-            rescoredDocs.scoreDocs = scoreDocs;
-            return rescoredDocs;
-          }
-
+        if(howMany == rescoredDocs.scoreDocs.length) {
+          return rescoredDocs; // Just return the rescoredDocs
+        } else if(howMany > rescoredDocs.scoreDocs.length) {
+          //We need to return more then we've reRanked, so create the combined page.
+          ScoreDoc[] scoreDocs = new ScoreDoc[howMany];
+          System.arraycopy(mainScoreDocs, 0, scoreDocs, 0, scoreDocs.length); //lay down the initial docs
+          System.arraycopy(rescoredDocs.scoreDocs, 0, scoreDocs, 0, rescoredDocs.scoreDocs.length);//overlay the re-ranked docs.
+          rescoredDocs.scoreDocs = scoreDocs;
+          return rescoredDocs;
         } else {
-
-          if(howMany == rescoredDocs.scoreDocs.length) {
-            return rescoredDocs; // Just return the rescoredDocs
-          } else if(howMany > rescoredDocs.scoreDocs.length) {
-
-            //We need to return more then we've reRanked, so create the combined page.
-            ScoreDoc[] scoreDocs = new ScoreDoc[howMany];
-            //lay down the initial docs
-            System.arraycopy(mainScoreDocs, 0, scoreDocs, 0, scoreDocs.length);
-            //overlay the rescoreds docs
-            System.arraycopy(rescoredDocs.scoreDocs, 0, scoreDocs, 0, rescoredDocs.scoreDocs.length);
-            rescoredDocs.scoreDocs = scoreDocs;
-            return rescoredDocs;
-          } else {
-            //We've rescored more then we need to return.
-            ScoreDoc[] scoreDocs = new ScoreDoc[howMany];
-            System.arraycopy(rescoredDocs.scoreDocs, 0, scoreDocs, 0, howMany);
-            rescoredDocs.scoreDocs = scoreDocs;
-            return rescoredDocs;
-          }
+          //We've rescored more then we need to return.
+          ScoreDoc[] scoreDocs = new ScoreDoc[howMany];
+          System.arraycopy(rescoredDocs.scoreDocs, 0, scoreDocs, 0, howMany);
+          rescoredDocs.scoreDocs = scoreDocs;
+          return rescoredDocs;
         }
       } catch (Exception e) {
         throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);