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.
MySQLJDBCDataModel
DEFAULT_DATASOURCE_NAME
Constructor and Description |
---|
MySQLJDBCItemSimilarity() |
MySQLJDBCItemSimilarity(DataSource dataSource) |
MySQLJDBCItemSimilarity(DataSource dataSource,
String similarityTable,
String itemAIDColumn,
String itemBIDColumn,
String similarityColumn) |
MySQLJDBCItemSimilarity(String dataSourceName) |
Modifier and Type | Method and Description |
---|---|
protected int |
getFetchSize() |
allSimilarItemIDs, getItemAIDColumn, getItemBIDColumn, getSimilarityColumn, getSimilarityTable, itemSimilarities, itemSimilarity, refresh
checkNotNullAndLog, checkNotNullAndLog, lookupDataSource
public MySQLJDBCItemSimilarity() throws TasteException
TasteException
public MySQLJDBCItemSimilarity(String dataSourceName) throws TasteException
TasteException
public MySQLJDBCItemSimilarity(DataSource dataSource)
public MySQLJDBCItemSimilarity(DataSource dataSource, String similarityTable, String itemAIDColumn, String itemBIDColumn, String similarityColumn)
protected int getFetchSize()
getFetchSize
in class AbstractJDBCComponent
Copyright © 2008–2017 The Apache Software Foundation. All rights reserved.