You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by sr...@apache.org on 2010/05/31 16:37:39 UTC

svn commit: r949757 - /mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/jdbc/AbstractJDBCItemSimilarity.java

Author: srowen
Date: Mon May 31 14:37:38 2010
New Revision: 949757

URL: http://svn.apache.org/viewvc?rev=949757&view=rev
Log:
MAHOUT-406

Modified:
    mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/jdbc/AbstractJDBCItemSimilarity.java

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/jdbc/AbstractJDBCItemSimilarity.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/jdbc/AbstractJDBCItemSimilarity.java?rev=949757&r1=949756&r2=949757&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/jdbc/AbstractJDBCItemSimilarity.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/jdbc/AbstractJDBCItemSimilarity.java Mon May 31 14:37:38 2010
@@ -25,7 +25,6 @@ import java.util.Collection;
 
 import javax.sql.DataSource;
 
-import org.apache.mahout.cf.taste.common.NoSuchItemException;
 import org.apache.mahout.cf.taste.common.Refreshable;
 import org.apache.mahout.cf.taste.common.TasteException;
 import org.apache.mahout.cf.taste.impl.common.jdbc.AbstractJDBCComponent;
@@ -73,9 +72,8 @@ public abstract class AbstractJDBCItemSi
     AbstractJDBCComponent.checkNotNullAndLog("getItemItemSimilaritySQL", getItemItemSimilaritySQL);
     
     if (!(dataSource instanceof ConnectionPoolDataSource)) {
-      log
-          .warn("You are not using ConnectionPoolDataSource. Make sure your DataSource pools connections "
-                + "to the database itself, or database performance will be severely reduced.");
+      log.warn("You are not using ConnectionPoolDataSource. Make sure your DataSource pools connections "
+               + "to the database itself, or database performance will be severely reduced.");
     }
     
     this.dataSource = dataSource;
@@ -130,12 +128,10 @@ public abstract class AbstractJDBCItemSi
       
       log.debug("Executing SQL query: {}", getItemItemSimilaritySQL);
       rs = stmt.executeQuery();
-      
-      if (rs.next()) {
-        return rs.getDouble(1);
-      } else {
-        throw new NoSuchItemException();
-      }
+
+      // If not found, perhaps the items exist but have no presence in the table,
+      // so NaN is appropriate
+      return rs.next() ? rs.getDouble(1) : Double.NaN;
       
     } catch (SQLException sqle) {
       log.warn("Exception while retrieving user", sqle);