mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r949757 - /mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/similarity/jdbc/AbstractJDBCItemSimilarity.java
Date Mon, 31 May 2010 14:37:39 GMT
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);



Mime
View raw message