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)
)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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
getFetchSize
protected int getFetchSize()
- Overrides:
getFetchSize
in class AbstractJDBCComponent
- See Also:
MySQLJDBCDataModel.getFetchSize()
Copyright © 2008-2012 The Apache Software Foundation. All Rights Reserved.