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) )
DEFAULT_AVERAGE_DIFF_COLUMN, DEFAULT_COUNT_COLUMN, DEFAULT_DIFF_TABLE, DEFAULT_ITEM_A_COLUMN, DEFAULT_ITEM_B_COLUMN, DEFAULT_STDEV_COLUMNDEFAULT_DATASOURCE_NAME| Constructor and Description |
|---|
MySQLJDBCDiffStorage(AbstractJDBCDataModel dataModel) |
MySQLJDBCDiffStorage(AbstractJDBCDataModel dataModel,
String diffsTable,
String itemIDAColumn,
String itemIDBColumn,
String countColumn,
String avgColumn,
String stdevColumn,
int minDiffCount) |
| Modifier and Type | Method and Description |
|---|---|
protected int |
getFetchSize() |
addItemPref, getAverageItemPref, getDiff, getDiffs, getRecommendableItemIDs, refresh, removeItemPref, updateItemPrefcheckNotNullAndLog, checkNotNullAndLog, lookupDataSourcepublic MySQLJDBCDiffStorage(AbstractJDBCDataModel dataModel) throws TasteException
TasteExceptionpublic MySQLJDBCDiffStorage(AbstractJDBCDataModel dataModel, String diffsTable, String itemIDAColumn, String itemIDBColumn, String countColumn, String avgColumn, String stdevColumn, int minDiffCount) throws TasteException
TasteExceptionprotected int getFetchSize()
getFetchSize in class AbstractJDBCComponentMySQLJDBCDataModel.getFetchSize()Copyright © 2008–2013 The Apache Software Foundation. All rights reserved.