org.apache.mahout.cf.taste.impl.recommender.slopeone.jdbc
Class AbstractJDBCDiffStorage
java.lang.Object
org.apache.mahout.cf.taste.impl.common.jdbc.AbstractJDBCComponent
org.apache.mahout.cf.taste.impl.recommender.slopeone.jdbc.AbstractJDBCDiffStorage
- All Implemented Interfaces:
- Refreshable, DiffStorage
- Direct Known Subclasses:
- MySQLJDBCDiffStorage
public abstract class AbstractJDBCDiffStorage
- extends AbstractJDBCComponent
- implements DiffStorage
A DiffStorage
which stores diffs in a database. Database-specific implementations subclass this
abstract class. Note that this implementation has a fairly particular dependence on the
DataModel
used; it needs a JDBCDataModel
attached to the
same database since its efficient operation depends on accessing preference data in the database directly.
Constructor Summary |
protected |
AbstractJDBCDiffStorage(JDBCDataModel dataModel,
String getDiffSQL,
String getDiffsSQL,
String getAverageItemPrefSQL,
String getDiffsAffectedByUserSQL,
String[] updateDiffSQLs,
String updateOneDiffSQL,
String addDiffSQL,
String removeDiffSQL,
String getRecommendableItemsSQL,
String deleteDiffsSQL,
String createDiffsSQL,
String diffsExistSQL,
int minDiffCount)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT_DIFF_TABLE
public static final String DEFAULT_DIFF_TABLE
- See Also:
- Constant Field Values
DEFAULT_ITEM_A_COLUMN
public static final String DEFAULT_ITEM_A_COLUMN
- See Also:
- Constant Field Values
DEFAULT_ITEM_B_COLUMN
public static final String DEFAULT_ITEM_B_COLUMN
- See Also:
- Constant Field Values
DEFAULT_COUNT_COLUMN
public static final String DEFAULT_COUNT_COLUMN
- See Also:
- Constant Field Values
DEFAULT_AVERAGE_DIFF_COLUMN
public static final String DEFAULT_AVERAGE_DIFF_COLUMN
- See Also:
- Constant Field Values
DEFAULT_STDEV_COLUMN
public static final String DEFAULT_STDEV_COLUMN
- See Also:
- Constant Field Values
AbstractJDBCDiffStorage
protected AbstractJDBCDiffStorage(JDBCDataModel dataModel,
String getDiffSQL,
String getDiffsSQL,
String getAverageItemPrefSQL,
String getDiffsAffectedByUserSQL,
String[] updateDiffSQLs,
String updateOneDiffSQL,
String addDiffSQL,
String removeDiffSQL,
String getRecommendableItemsSQL,
String deleteDiffsSQL,
String createDiffsSQL,
String diffsExistSQL,
int minDiffCount)
throws TasteException
- Throws:
TasteException
getDiff
public RunningAverage getDiff(long itemID1,
long itemID2)
throws TasteException
- Specified by:
getDiff
in interface DiffStorage
- Throws:
TasteException
getDiffs
public RunningAverage[] getDiffs(long userID,
long itemID,
PreferenceArray prefs)
throws TasteException
- Specified by:
getDiffs
in interface DiffStorage
- Throws:
TasteException
getAverageItemPref
public RunningAverage getAverageItemPref(long itemID)
throws TasteException
- Specified by:
getAverageItemPref
in interface DiffStorage
- Throws:
TasteException
addItemPref
public void addItemPref(long userID,
long itemID,
float prefValue)
throws TasteException
- Specified by:
addItemPref
in interface DiffStorage
- Throws:
TasteException
updateItemPref
public void updateItemPref(long itemID,
float prefDelta)
throws TasteException
- Note that this implementation does not update standard deviations. This would
be expensive relative to the value of slightly adjusting these values, which are merely
used as weighted. Rebuilding the diffs table will update standard deviations.
- Specified by:
updateItemPref
in interface DiffStorage
- Throws:
TasteException
removeItemPref
public void removeItemPref(long userID,
long itemID,
float prefValue)
throws TasteException
- Specified by:
removeItemPref
in interface DiffStorage
- Throws:
TasteException
getRecommendableItemIDs
public FastIDSet getRecommendableItemIDs(long userID)
throws TasteException
- Specified by:
getRecommendableItemIDs
in interface DiffStorage
- Throws:
TasteException
refresh
public void refresh(Collection<Refreshable> alreadyRefreshed)
- Specified by:
refresh
in interface Refreshable
Copyright © 2008-2012 The Apache Software Foundation. All Rights Reserved.