## 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`

Field Summary

Fields inherited from class org.apache.mahout.cf.taste.impl.common.jdbc.AbstractJDBCComponent
`DEFAULT_DATASOURCE_NAME`

Constructor Summary
`MySQLJDBCItemSimilarity()`
`MySQLJDBCItemSimilarity(DataSource dataSource)`
`MySQLJDBCItemSimilarity(DataSource dataSource, String similarityTable, String itemAIDColumn, String itemBIDColumn, String similarityColumn)`
`MySQLJDBCItemSimilarity(String dataSourceName)`

Method Summary
`protected int` `getFetchSize()`

Methods inherited from class org.apache.mahout.cf.taste.impl.similarity.jdbc.AbstractJDBCItemSimilarity
`allSimilarItemIDs, getItemAIDColumn, getItemBIDColumn, getSimilarityColumn, getSimilarityTable, itemSimilarities, itemSimilarity, refresh`

Methods inherited from class org.apache.mahout.cf.taste.impl.common.jdbc.AbstractJDBCComponent
`checkNotNullAndLog, checkNotNullAndLog, lookupDataSource`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### 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)

Method Detail

### getFetchSize

    protected int getFetchSize()

  Overrides:
    `getFetchSize` in class `AbstractJDBCComponent`

Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.