org.mymedialite.data
Class TimedRatings
java.lang.Object
org.mymedialite.data.DataSet
org.mymedialite.data.Ratings
org.mymedialite.data.TimedRatings
- All Implemented Interfaces:
- java.util.Comparator<java.lang.Integer>, IDataSet, IRatings, ITimedDataSet, ITimedRatings
- Direct Known Subclasses:
- TimedRatingsProxy
public class TimedRatings
- extends Ratings
- implements ITimedRatings
Data structure for storing ratings with time information.
Small memory overhead for added flexibility.
This data structure supports incremental updates.
Loading the Netflix Prize data set (100,000,000 ratings) into this data structure requires about 3.2 GB of memory.
Method Summary |
void |
add(int user_id,
int item_id,
double rating)
Add a new rating. |
void |
add(int user_id,
int item_id,
double rating,
java.util.Date time)
Add a rating event including time information. |
int |
compare(java.lang.Integer index1,
java.lang.Integer index2)
Compares the dates of two entries in the Dataset. |
java.util.Date |
earliestTime()
earliest time. |
java.util.Date |
latestTime()
latest time. |
java.util.List<java.util.Date> |
times()
the item entries. |
Methods inherited from class org.mymedialite.data.Ratings |
add, add, average, buildByItemCounts, buildByUserCounts, countByItem, countByUser, get, get, get, isReadOnly, maxRating, minRating, removeAt, removeItem, removeUser, set, tryGet, tryGet, tryGetIndex, values |
Methods inherited from class org.mymedialite.data.DataSet |
allItems, allUsers, buildItemIndices, buildRandomIndex, buildUserIndices, byItem, byUser, getIndex, getIndex, getItems, getUsers, items, maxItemID, maxUserID, randomIndex, size, tryGetIndex, users |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.mymedialite.data.IRatings |
add, add, average, countByItem, countByUser, get, get, get, maxRating, minRating, removeAt, set, size, tryGet, tryGet, values |
Methods inherited from interface org.mymedialite.data.IDataSet |
allItems, allUsers, buildItemIndices, buildRandomIndex, buildUserIndices, byItem, byUser, getIndex, getIndex, getItems, getUsers, items, maxItemID, maxUserID, randomIndex, removeItem, removeUser, tryGetIndex, tryGetIndex, users |
Methods inherited from interface java.util.Comparator |
equals |
times
protected java.util.List<java.util.Date> times
earliestTime
protected java.util.Date earliestTime
latestTime
protected java.util.Date latestTime
TimedRatings
public TimedRatings()
- Default constructor.
times
public java.util.List<java.util.Date> times()
- Description copied from interface:
ITimedDataSet
- the item entries.
- Specified by:
times
in interface ITimedDataSet
earliestTime
public java.util.Date earliestTime()
- Description copied from interface:
ITimedDataSet
- earliest time.
- Specified by:
earliestTime
in interface ITimedDataSet
latestTime
public java.util.Date latestTime()
- Description copied from interface:
ITimedDataSet
- latest time.
- Specified by:
latestTime
in interface ITimedDataSet
add
public void add(int user_id,
int item_id,
double rating)
- Description copied from interface:
IRatings
- Add a new rating.
- Specified by:
add
in interface IRatings
- Overrides:
add
in class Ratings
- Parameters:
user_id
- the user IDitem_id
- the item IDrating
- the rating value
add
public void add(int user_id,
int item_id,
double rating,
java.util.Date time)
- Description copied from interface:
ITimedRatings
- Add a rating event including time information.
It is up to the user of a class implementing this interface to decide whether the DateTime
object represent local time, UTC, or any other time.
- Specified by:
add
in interface ITimedRatings
- Parameters:
user_id
- the user IDitem_id
- the item IDrating
- the rating valuetime
- a Date specifying the time of the rating event
compare
public int compare(java.lang.Integer index1,
java.lang.Integer index2)
- Description copied from interface:
ITimedDataSet
- Compares the dates of two entries in the Dataset.
- Specified by:
compare
in interface java.util.Comparator<java.lang.Integer>
- Specified by:
compare
in interface ITimedDataSet
- Parameters:
index1
- the index of the first entryindex2
- the index of the second entry
- Returns:
- the value 0 if the date of the two entries is equal; a value less than 0 if the date of the first entry is before the date of the second entry; and a value greater than 0 if the date of the first entry is after the date of the second entry.