cpoerschke commented on a change in pull request #189:
URL: https://github.com/apache/solr/pull/189#discussion_r658113292



##########
File path: solr/contrib/ltr/src/java/org/apache/solr/ltr/LTRRescorer.java
##########
@@ -118,52 +112,63 @@ public TopDocs rescore(IndexSearcher searcher, TopDocs 
firstPassTopDocs,
     return new TopDocs(firstPassTopDocs.totalHits, reranked);
   }
 
-  private ScoreDoc[] rerank(IndexSearcher searcher, int topN, ScoreDoc[] 
firstPassResults) throws IOException {
+  private ScoreDoc[] rerank(IndexSearcher searcher, int topN, ScoreDoc[] 
firstPassResults)
+      throws IOException {
     final ScoreDoc[] reranked = new ScoreDoc[topN];
     final List<LeafReaderContext> leaves = searcher.getIndexReader().leaves();
-    final LTRScoringQuery.ModelWeight modelWeight = 
(LTRScoringQuery.ModelWeight) searcher
-        .createWeight(searcher.rewrite(scoringQuery), ScoreMode.COMPLETE, 1);
+    final LTRScoringQuery.ModelWeight modelWeight =
+        (LTRScoringQuery.ModelWeight)
+            searcher.createWeight(searcher.rewrite(scoringQuery), 
ScoreMode.COMPLETE, 1);
 
-    scoreFeatures(searcher,topN, modelWeight, firstPassResults, leaves, 
reranked);
+    scoreFeatures(searcher, topN, modelWeight, firstPassResults, leaves, 
reranked);
     // Must sort all documents that we reranked, and then select the top
     sortByScore(reranked);
     return reranked;
   }
 
   protected static void sortByScore(ScoreDoc[] reranked) {
-    Arrays.sort(reranked, new Comparator<ScoreDoc>() {
-      @Override
-      public int compare(ScoreDoc a, ScoreDoc b) {
-        // Sort by score descending, then docID ascending:
-        if (a.score > b.score) {
-          return -1;
-        } else if (a.score < b.score) {
-          return 1;
-        } else {
-          // This subtraction can't overflow int
-          // because docIDs are >= 0:
-          return a.doc - b.doc;
-        }
-      }
-    });
+    Arrays.sort(
+        reranked,
+        new Comparator<ScoreDoc>() {

Review comment:
       > probably outside of scope here, but we could make a static instance of 
this comparator and reuse it.
   
   https://issues.apache.org/jira/browse/SOLR-15496 created for it.




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to