public final class CachingItemSimilarity extends Object implements ItemSimilarity
ItemSimilarity
implementation.Constructor and Description |
---|
CachingItemSimilarity(ItemSimilarity similarity,
DataModel dataModel)
Creates this on top of the given
ItemSimilarity . |
CachingItemSimilarity(ItemSimilarity similarity,
int maxCacheSize)
Creates this on top of the given
ItemSimilarity . |
Modifier and Type | Method and Description |
---|---|
long[] |
allSimilarItemIDs(long itemID) |
void |
clearCacheForItem(long itemID) |
double[] |
itemSimilarities(long itemID1,
long[] itemID2s)
A bulk-get version of
ItemSimilarity.itemSimilarity(long, long) . |
double |
itemSimilarity(long itemID1,
long itemID2)
Returns the degree of similarity, of two items, based on the preferences that users have expressed for
the items.
|
void |
refresh(Collection<Refreshable> alreadyRefreshed)
Triggers "refresh" -- whatever that means -- of the implementation.
|
public CachingItemSimilarity(ItemSimilarity similarity, DataModel dataModel) throws TasteException
ItemSimilarity
.
The cache is sized according to properties of the given DataModel
.TasteException
public CachingItemSimilarity(ItemSimilarity similarity, int maxCacheSize)
ItemSimilarity
.
The cache size is capped by the given size.public double itemSimilarity(long itemID1, long itemID2) throws TasteException
ItemSimilarity
Returns the degree of similarity, of two items, based on the preferences that users have expressed for the items.
itemSimilarity
in interface ItemSimilarity
itemID1
- first item IDitemID2
- second item IDDouble.NaN
similarity is unknownNoSuchItemException
- if either item is known to be non-existent in the dataTasteException
- if an error occurs while accessing the datapublic double[] itemSimilarities(long itemID1, long[] itemID2s) throws TasteException
ItemSimilarity
A bulk-get version of ItemSimilarity.itemSimilarity(long, long)
.
itemSimilarities
in interface ItemSimilarity
itemID1
- first item IDitemID2s
- second item IDs to compute similarity withNoSuchItemException
- if any item is known to be non-existent in the dataTasteException
- if an error occurs while accessing the datapublic long[] allSimilarItemIDs(long itemID) throws TasteException
allSimilarItemIDs
in interface ItemSimilarity
TasteException
public void refresh(Collection<Refreshable> alreadyRefreshed)
Refreshable
Triggers "refresh" -- whatever that means -- of the implementation. The general contract is that any
Refreshable
should always leave itself in a consistent, operational state, and that the refresh
atomically updates internal state from old to new.
refresh
in interface Refreshable
alreadyRefreshed
- Refreshable
s that are known to have already been
refreshed as a result of an initial call to a {#refresh(Collection)} method on some
object. This ensure that objects in a refresh dependency graph aren't refreshed twice
needlessly.public void clearCacheForItem(long itemID)
Copyright © 2008–2017 The Apache Software Foundation. All rights reserved.