org.mymedialite.data
Class StaticRatings

java.lang.Object
  extended by org.mymedialite.data.DataSet
      extended by org.mymedialite.data.Ratings
          extended by org.mymedialite.data.StaticRatings
All Implemented Interfaces:
IDataSet, IRatings
Direct Known Subclasses:
StaticByteRatings, StaticFloatRatings

public class StaticRatings
extends Ratings

Array-based storage for rating data.. Very memory-efficient. This data structure does NOT support incremental updates.


Field Summary
protected  int pos
          The position where the next rating will be stored.
 
Fields inherited from class org.mymedialite.data.Ratings
maxRating, minRating, values
 
Fields inherited from class org.mymedialite.data.DataSet
byItem, byUser, items, maxItemID, maxUserID, users
 
Constructor Summary
StaticRatings()
           
StaticRatings(int size)
           
 
Method Summary
 void add(int user_id, int item_id, double rating)
          Add a new rating.
 void removeAt(int index)
          Remove the rating at the specified index
 void removeItem(int item_id)
          Remove all events related to a given item.
 void removeUser(int user_id)
          Remove all events related to a given user.
 int size()
           
 
Methods inherited from class org.mymedialite.data.Ratings
add, add, average, buildByItemCounts, buildByUserCounts, countByItem, countByUser, get, get, get, isReadOnly, maxRating, minRating, 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, 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.IDataSet
allItems, allUsers, buildItemIndices, buildRandomIndex, buildUserIndices, byItem, byUser, getIndex, getIndex, getItems, getUsers, items, maxItemID, maxUserID, randomIndex, tryGetIndex, users
 

Field Detail

pos

protected int pos
The position where the next rating will be stored.

Constructor Detail

StaticRatings

public StaticRatings()

StaticRatings

public StaticRatings(int size)
Method Detail

size

public int size()
Specified by:
size in interface IDataSet
Specified by:
size in interface IRatings
Overrides:
size in class DataSet
Returns:
the number of interaction events in the dataset.

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 ID
item_id - the item ID
rating - the rating value
Throws:
java.lang.IndexOutOfBoundsException

removeAt

public void removeAt(int index)
Description copied from interface: IRatings
Remove the rating at the specified index

Specified by:
removeAt in interface IRatings
Overrides:
removeAt in class Ratings
Parameters:
index - the rating index

removeUser

public void removeUser(int user_id)
Description copied from interface: IDataSet
Remove all events related to a given user.

Specified by:
removeUser in interface IDataSet
Overrides:
removeUser in class Ratings
Parameters:
user_id - the user ID

removeItem

public void removeItem(int item_id)
Description copied from interface: IDataSet
Remove all events related to a given item.

Specified by:
removeItem in interface IDataSet
Overrides:
removeItem in class Ratings
Parameters:
item_id - the item ID