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

    java.lang.Object
      org.apache.mahout.cf.taste.impl.common.jdbc.AbstractJDBCComponent
          org.apache.mahout.cf.taste.impl.recommender.slopeone.jdbc.AbstractJDBCDiffStorage
              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, java.lang.String diffsTable, java.lang.String itemIDAColumn, java.lang.String itemIDBColumn, java.lang.String countColumn, java.lang.String avgColumn, java.lang.String stdevColumn, int minDiffCount)`

Method Summary
`protected int` `getFetchSize()`

Methods inherited from class org.apache.mahout.cf.taste.impl.recommender.slopeone.jdbc.AbstractJDBCDiffStorage
`getAverageItemPref, getDiff, getDiffs, getRecommendableItemIDs, refresh, updateItemPref`

Methods inherited from class org.apache.mahout.cf.taste.impl.common.jdbc.AbstractJDBCComponent
`advanceResultSet, 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,
                                java.lang.String diffsTable,
                                java.lang.String itemIDAColumn,
                                java.lang.String itemIDBColumn,
                                java.lang.String countColumn,
                                java.lang.String avgColumn,
                                java.lang.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-2010 The Apache Software Foundation. All Rights Reserved.