@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()
RatingMatrix
Get the set of user IDs in the snapshot.
getUserIds
in interface RatingMatrix
public LongCollection getItemIds()
RatingMatrix
Get the set of item IDs in the snapshot.
getItemIds
in interface RatingMatrix
public KeyIndex userIndex()
RatingMatrix
Get the user ID index.
userIndex
in interface RatingMatrix
public KeyIndex itemIndex()
RatingMatrix
Get the item ID index.
itemIndex
in interface RatingMatrix
public java.util.List<RatingMatrixEntry> getRatings()
RatingMatrix
Get 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 RatingMatrix
public java.util.Collection<RatingMatrixEntry> getUserRatings(long userId)
RatingMatrix
Get 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 RatingMatrix
userId
- The user’s ID.public Long2DoubleMap getUserRatingVector(long userId)
RatingMatrix
Get the current preferences of a particular user as a vector.
getUserRatingVector
in interface RatingMatrix
userId
- 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.