lewismc commented on a change in pull request #9: SDAP-52 Improve ranking speed
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/9#discussion_r176634661
 
 

 ##########
 File path: core/src/main/java/org/apache/sdap/mudrod/ssearch/Ranker.java
 ##########
 @@ -147,42 +137,32 @@ private double getNDForm(double d) {
       }
     }
 
-    // using collection.sort directly would cause an "not transitive" error
-    // this is because the training model is not a overfitting model
-    for (int j = 0; j < resultList.size(); j++) {
-      for (int k = 0; k < resultList.size(); k++) {
-        if (k != j) {
-          resultList.get(j).below += comp(resultList.get(j), 
resultList.get(k));
-        }
-      }
-    }
-
     Collections.sort(resultList, new ResultComparator());
     return resultList;
   }
-
+  
   /**
-   * Method of compare two search resutls
-   *
-   * @param o1 search result 1
-   * @param o2 search result 2
-   * @return 1 if o1 is greater than o2, 0 otherwise
+   * Method of comparing results based on final score
    */
-  public int comp(SResult o1, SResult o2) {
-    List<Double> instList = new ArrayList<>();
-    for (int i = 0; i < SResult.rlist.length; i++) {
-      double o2Score = SResult.get(o2, SResult.rlist[i]);
-      double o1Score = SResult.get(o1, SResult.rlist[i]);
-      instList.add(o2Score - o1Score);
-    }
+  public class ResultComparator implements Comparator<SResult> {
+    @Override
+    public int compare(SResult o1, SResult o2) {
+      List<Double> instList = new ArrayList<>();
+      for (int i = 0; i < SResult.rlist.length; i++) {
 
 Review comment:
   Please use the enhanced for loop notation
   ```
   for (SResult result: SResult.rlist.length)
   ```
   This prevents the additional rlist([i]) accessors which is messy. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services

Reply via email to