mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r808858 - in /lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model: GenericItemPreferenceArray.java GenericUserPreferenceArray.java
Date Fri, 28 Aug 2009 12:21:34 GMT
Author: srowen
Date: Fri Aug 28 12:21:33 2009
New Revision: 808858

URL: http://svn.apache.org/viewvc?rev=808858&view=rev
Log:
Small sorting optimization since pref data is frequently already ordered.

Modified:
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericItemPreferenceArray.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericUserPreferenceArray.java

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericItemPreferenceArray.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericItemPreferenceArray.java?rev=808858&r1=808857&r2=808858&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericItemPreferenceArray.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericItemPreferenceArray.java
Fri Aug 28 12:21:33 2009
@@ -129,6 +129,16 @@
   private void selectionSort(int type) {
     // I think this sort will prove to be too dumb, but, it's in place and OK for tiny, mostly
sorted data
     int max = length();
+    boolean sorted = true;
+    for (int i = 1; i < max; i++) {
+      if (isLess(i, i-1, type)) {
+        sorted = false;
+        break;
+      }
+    }
+    if (sorted) {
+      return;
+    }
     for (int i = 0; i < max; i++) {
       int min = i;
       for (int j = i + 1; j < max; j++) {

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericUserPreferenceArray.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericUserPreferenceArray.java?rev=808858&r1=808857&r2=808858&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericUserPreferenceArray.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/model/GenericUserPreferenceArray.java
Fri Aug 28 12:21:33 2009
@@ -130,6 +130,16 @@
   private void selectionSort(int type) {
     // I think this sort will prove to be too dumb, but, it's in place and OK for tiny, mostly
sorted data
     int max = length();
+    boolean sorted = true;
+    for (int i = 1; i < max; i++) {
+      if (isLess(i, i-1, type)) {
+        sorted = false;
+        break;
+      }
+    }
+    if (sorted) {
+      return;
+    }
     for (int i = 0; i < max; i++) {
       int min = i;
       for (int j = i + 1; j < max; j++) {



Mime
View raw message