org.apache.mahout.cf.taste.impl.recommender.slopeone.jdbc
Class MySQLJDBCDiffStorage

java.lang.Object
  extended by org.apache.mahout.cf.taste.impl.common.jdbc.AbstractJDBCComponent
      extended by org.apache.mahout.cf.taste.impl.recommender.slopeone.jdbc.AbstractJDBCDiffStorage
          extended by org.apache.mahout.cf.taste.impl.recommender.slopeone.jdbc.MySQLJDBCDiffStorage
All Implemented Interfaces:
Refreshable, DiffStorage

public final class MySQLJDBCDiffStorage
extends AbstractJDBCDiffStorage

MySQL-specific implementation. Should be used in conjunction with a MySQLJDBCDataModel. This implementation stores item-item diffs in a MySQL database and encapsulates some other slope-one-specific operations that are needed on the preference data in the database. It assumes the database has a schema like:

item_id_a item_id_b average_diff standard_deviation count
123 234 0.5 0.12 5
123 789 -1.33 0.2 3
234 789 2.1 1.03 1

item_id_a and item_id_b should have types compatible with the long primitive type. average_diff and standard_deviation must be compatible with float and count must be compatible with int.

The following command sets up a suitable table in MySQL:

 CREATE TABLE taste_slopeone_diffs (
   item_id_a BIGINT NOT NULL,
   item_id_b BIGINT NOT NULL,
   average_diff FLOAT NOT NULL,
   standard_deviation FLOAT NOT NULL,
   count INT NOT NULL,
   PRIMARY KEY (item_id_a, item_id_b),
   INDEX (item_id_a),
   INDEX (item_id_b)
 )
 


Field Summary
 
Fields inherited from class org.apache.mahout.cf.taste.impl.recommender.slopeone.jdbc.AbstractJDBCDiffStorage
DEFAULT_AVERAGE_DIFF_COLUMN, DEFAULT_COUNT_COLUMN, DEFAULT_DIFF_TABLE, DEFAULT_ITEM_A_COLUMN, DEFAULT_ITEM_B_COLUMN, DEFAULT_STDEV_COLUMN
 
Fields inherited from class org.apache.mahout.cf.taste.impl.common.jdbc.AbstractJDBCComponent
DEFAULT_DATASOURCE_NAME
 
Constructor Summary
MySQLJDBCDiffStorage(AbstractJDBCDataModel dataModel)
           
MySQLJDBCDiffStorage(AbstractJDBCDataModel dataModel, String diffsTable, String itemIDAColumn, String itemIDBColumn, String countColumn, String avgColumn, String stdevColumn, int minDiffCount)
           
 
Method Summary
protected  int getFetchSize()
           
 
Methods inherited from class org.apache.mahout.cf.taste.impl.recommender.slopeone.jdbc.AbstractJDBCDiffStorage
addItemPref, getAverageItemPref, getDiff, getDiffs, getRecommendableItemIDs, refresh, removeItemPref, updateItemPref
 
Methods inherited from class org.apache.mahout.cf.taste.impl.common.jdbc.AbstractJDBCComponent
checkNotNullAndLog, checkNotNullAndLog, lookupDataSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MySQLJDBCDiffStorage

public MySQLJDBCDiffStorage(AbstractJDBCDataModel dataModel)
                     throws TasteException
Throws:
TasteException

MySQLJDBCDiffStorage

public MySQLJDBCDiffStorage(AbstractJDBCDataModel dataModel,
                            String diffsTable,
                            String itemIDAColumn,
                            String itemIDBColumn,
                            String countColumn,
                            String avgColumn,
                            String stdevColumn,
                            int minDiffCount)
                     throws TasteException
Throws:
TasteException
Method Detail

getFetchSize

protected int getFetchSize()
Overrides:
getFetchSize in class AbstractJDBCComponent
See Also:
MySQLJDBCDataModel.getFetchSize()


Copyright © 2008-2012 The Apache Software Foundation. All Rights Reserved.