@DefaultProvider(value=PackedRatingMatrixProvider.class) @Shareable public class PackedRatingMatrix extends java.lang.Object implements RatingMatrix
An in-memory snapshot of rating data stored in packed arrays.
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Dispose of the internal memory in the packed rating matrix.
|
LongCollection |
getItemIds()
Get the set of item IDs in the snapshot.
|
java.util.List<RatingMatrixEntry> |
getRatings()
Get the collection of ratings in the snapshot.
|
LongCollection |
getUserIds()
Get the set of user IDs in the snapshot.
|
java.util.Collection<RatingMatrixEntry> |
getUserRatings(long userId)
Get the ratings for a particular user.
|
Long2DoubleMap |
getUserRatingVector(long userId)
Get the current preferences of a particular user as a vector.
|
KeyIndex |
itemIndex()
Get the item ID index.
|
KeyIndex |
userIndex()
Get the user ID index.
|
public LongCollection getUserIds()
RatingMatrixGet the set of user IDs in the snapshot.
getUserIds in interface RatingMatrixpublic LongCollection getItemIds()
RatingMatrixGet the set of item IDs in the snapshot.
getItemIds in interface RatingMatrixpublic KeyIndex userIndex()
RatingMatrixGet the user ID index.
userIndex in interface RatingMatrixpublic KeyIndex itemIndex()
RatingMatrixGet the item ID index.
itemIndex in interface RatingMatrixpublic java.util.List<RatingMatrixEntry> getRatings()
RatingMatrixGet the collection of ratings in the snapshot. The ratings are returned in an undetermined order. It is guaranteed that no duplicate ratings appear - each (user,item) pair is rated at most once. Each preference’s index is also in the range [0,len), where len is the size of this collection.
Modifying the returned indexed preferences will not modify the underlying snapshot.
getRatings in interface RatingMatrixpublic java.util.Collection<RatingMatrixEntry> getUserRatings(long userId)
RatingMatrixGet the ratings for a particular user. It is guaranteed that no duplicate ratings appear - each (user,item) pair is rated at most once.
Modifying the returned indexed preferences will not modify the underlying snapshot.
getUserRatings in interface RatingMatrixuserId - The user’s ID.public Long2DoubleMap getUserRatingVector(long userId)
RatingMatrixGet the current preferences of a particular user as a vector.
getUserRatingVector in interface RatingMatrixuserId - The user’s ID.@PreDestroy public void dispose()
Dispose of the internal memory in the packed rating matrix. It is not necessary to call this method, but it is present to free extra memory references early.