org.apache.mahout.cf.taste.impl.similarity.jdbc
Class MySQLJDBCItemSimilarity
java.lang.Object
org.apache.mahout.cf.taste.impl.common.jdbc.AbstractJDBCComponent
org.apache.mahout.cf.taste.impl.similarity.jdbc.AbstractJDBCItemSimilarity
org.apache.mahout.cf.taste.impl.similarity.jdbc.SQL92JDBCItemSimilarity
org.apache.mahout.cf.taste.impl.similarity.jdbc.MySQLJDBCItemSimilarity
- All Implemented Interfaces:
- Refreshable, ItemSimilarity
public class MySQLJDBCItemSimilarity
- extends SQL92JDBCItemSimilarity
An ItemSimilarity
backed by a MySQL database
and accessed via JDBC. It may work with other JDBC
databases. By default, this class assumes that there is a DataSource
available under the JNDI name
"jdbc/taste", which gives access to a database with a "taste_item_similarity" table with the following
schema:
item_id_a |
item_id_b |
similarity |
ABC |
DEF |
0.9 |
DEF |
EFG |
0.1 |
For example, the following command sets up a suitable table in MySQL, complete with primary key and
indexes:
CREATE TABLE taste_item_similarity (
item_id_a BIGINT NOT NULL,
item_id_b BIGINT NOT NULL,
similarity FLOAT NOT NULL,
PRIMARY KEY (item_id_a, item_id_b),
)
Note that for each row, item_id_a should be less than item_id_b. It is redundant to store it both ways,
so the pair is always stored as a pair with the lesser one first.
- See Also:
slopeone.jdbc.MySQLJDBCDiffStorage
,
MySQLJDBCDataModel
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MySQLJDBCItemSimilarity
public MySQLJDBCItemSimilarity()
throws TasteException
- Throws:
TasteException
MySQLJDBCItemSimilarity
public MySQLJDBCItemSimilarity(String dataSourceName)
throws TasteException
- Throws:
TasteException
MySQLJDBCItemSimilarity
public MySQLJDBCItemSimilarity(DataSource dataSource)
MySQLJDBCItemSimilarity
public MySQLJDBCItemSimilarity(DataSource dataSource,
String similarityTable,
String itemAIDColumn,
String itemBIDColumn,
String similarityColumn)
getFetchSize
protected int getFetchSize()
- Overrides:
getFetchSize
in class AbstractJDBCComponent
Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.