## org.apache.mahout.cf.taste.impl.model.jdbc
Class AbstractBooleanPrefJDBCDataModel

    java.lang.Object
      org.apache.mahout.cf.taste.impl.common.jdbc.AbstractJDBCComponent
          org.apache.mahout.cf.taste.impl.model.jdbc.AbstractJDBCDataModel
              org.apache.mahout.cf.taste.impl.model.jdbc.AbstractBooleanPrefJDBCDataModel

All Implemented Interfaces:
  java.io.Serializable, Refreshable, DataModel, JDBCDataModel

Direct Known Subclasses:
  MySQLBooleanPrefJDBCDataModel

    public abstract class AbstractBooleanPrefJDBCDataModel

extends AbstractJDBCDataModel

See Also:
  Serialized Form

Field Summary

Fields inherited from class org.apache.mahout.cf.taste.impl.model.jdbc.AbstractJDBCDataModel
`DEFAULT_ITEM_ID_COLUMN, DEFAULT_PREFERENCE_COLUMN, DEFAULT_PREFERENCE_TABLE, DEFAULT_PREFERENCE_TIME_COLUMN, DEFAULT_USER_ID_COLUMN`

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

Constructor Summary

`protected`

`AbstractBooleanPrefJDBCDataModel(javax.sql.DataSource dataSource, java.lang.String preferenceTable, java.lang.String userIDColumn, java.lang.String itemIDColumn, java.lang.String preferenceColumn, java.lang.String getPreferenceSQL, java.lang.String getPreferenceTimeSQL, java.lang.String getUserSQL, java.lang.String getAllUsersSQL, java.lang.String getNumItemsSQL, java.lang.String getNumUsersSQL, java.lang.String setPreferenceSQL, java.lang.String removePreferenceSQL, java.lang.String getUsersSQL, java.lang.String getItemsSQL, java.lang.String getPrefsForItemSQL, java.lang.String getNumPreferenceForItemSQL, java.lang.String getNumPreferenceForItemsSQL, java.lang.String getMaxPreferenceSQL, java.lang.String getMinPreferenceSQL)`

Method Summary
`protected Preference` `buildPreference(java.sql.ResultSet rs)`
`float` `getMaxPreference()`
`float` `getMinPreference()`
`boolean` `hasPreferenceValues()`
`void` `setPreference(long userID, long itemID, float value)` Sets a particular preference (item plus rating) for a user.

Methods inherited from class org.apache.mahout.cf.taste.impl.model.jdbc.AbstractJDBCDataModel
`doGetPreferencesForItem, exportWithIDsOnly, exportWithPrefs, getDataSource, getItemIDColumn, getItemIDs, getItemIDsFromUser, getLongColumn, getNumItems, getNumUsers, getNumUsersWithPreferenceFor, getPreferenceColumn, getPreferencesForItem, getPreferencesFromUser, getPreferenceTable, getPreferenceTime, getPreferenceValue, getUserIDColumn, getUserIDs, refresh, removePreference, setLongParameter`

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

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

Constructor Detail

### AbstractBooleanPrefJDBCDataModel

    protected AbstractBooleanPrefJDBCDataModel(javax.sql.DataSource dataSource,
                                               java.lang.String preferenceTable,
                                               java.lang.String userIDColumn,
                                               java.lang.String itemIDColumn,
                                               java.lang.String preferenceColumn,
                                               java.lang.String getPreferenceSQL,
                                               java.lang.String getPreferenceTimeSQL,
                                               java.lang.String getUserSQL,
                                               java.lang.String getAllUsersSQL,
                                               java.lang.String getNumItemsSQL,
                                               java.lang.String getNumUsersSQL,
                                               java.lang.String setPreferenceSQL,
                                               java.lang.String removePreferenceSQL,
                                               java.lang.String getUsersSQL,
                                               java.lang.String getItemsSQL,
                                               java.lang.String getPrefsForItemSQL,
                                               java.lang.String getNumPreferenceForItemSQL,
                                               java.lang.String getNumPreferenceForItemsSQL,
                                               java.lang.String getMaxPreferenceSQL,
                                               java.lang.String getMinPreferenceSQL)

Method Detail

### buildPreference

    protected Preference buildPreference(java.sql.ResultSet rs)
                                  throws java.sql.SQLException

  Overrides:
    `buildPreference` in class `AbstractJDBCDataModel`
  Throws:
    `java.sql.SQLException`

### setPreference

    public void setPreference(long userID,
                              long itemID,
                              float value)
                       throws TasteException

  Description copied from interface: `DataModel`

  Sets a particular preference (item plus rating) for a user.

  Specified by:
    `setPreference` in interface `DataModel`
  Overrides:
    `setPreference` in class `AbstractJDBCDataModel`
  Parameters:
    `userID` - user to set preference for
    `itemID` - item to set preference for
    `value` - preference value
  Throws:
    `NoSuchItemException` - if the item does not exist
    `NoSuchUserException` - if the user does not exist
    `TasteException` - if an error occurs while accessing the data

### hasPreferenceValues

    public boolean hasPreferenceValues()

  Specified by:
    `hasPreferenceValues` in interface `DataModel`
  Overrides:
    `hasPreferenceValues` in class `AbstractJDBCDataModel`
  Returns:
    true iff this implementation actually stores and returns distinct preference values; that is, if it is not a 'boolean' DataModel

### getMaxPreference

    public float getMaxPreference()

  Specified by:
    `getMaxPreference` in interface `DataModel`
  Overrides:
    `getMaxPreference` in class `AbstractJDBCDataModel`
  Returns:
    the maximum preference value that is possible in the current problem domain being evaluated. For example, if the domain is movie ratings on a scale of 1 to 5, this should be 5. While a `Recommender` may estimate a preference value above 5.0, it isn't "fair" to consider that the system is actually suggesting an impossible rating of, say, 5.4 stars. In practice the application would cap this estimate to 5.0. Since evaluators evaluate the difference between estimated and actual value, this at least prevents this effect from unfairly penalizing a `Recommender`

### getMinPreference

    public float getMinPreference()

  Specified by:
    `getMinPreference` in interface `DataModel`
  Overrides:
    `getMinPreference` in class `AbstractJDBCDataModel`
  See Also:
    `DataModel.getMaxPreference()`

Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.