org.mymedialite.data
Class StaticByteRatings

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

public class StaticByteRatings
extends StaticRatings

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


Field Summary
 
Fields inherited from class org.mymedialite.data.StaticRatings
pos
 
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
StaticByteRatings(int size)
           
 
Method Summary
 void add(int user_id, int item_id, byte rating)
          Add byte-valued rating to the collection.
 void add(int user_id, int item_id, double rating)
          Add a new rating.
 double get(int index)
          Directly access ratings.
 double get(int user_id, int item_id)
          Directly access rating by user and item
 double get(int user_id, int item_id, IntCollection indexes)
          Directly access rating by user and item.
 double set(int index, double rating)
          Directly access the ratings
 java.lang.Double tryGet(int user_id, int item_id)
          Try to retrieve a rating for a given user-item combination.
 java.lang.Double tryGet(int user_id, int item_id, IntCollection indexes)
          Try to retrieve a rating for a given user-item combination.
 
Methods inherited from class org.mymedialite.data.StaticRatings
removeAt, removeItem, removeUser, size
 
Methods inherited from class org.mymedialite.data.Ratings
add, average, buildByItemCounts, buildByUserCounts, countByItem, countByUser, isReadOnly, maxRating, minRating, 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
 

Constructor Detail

StaticByteRatings

public StaticByteRatings(int size)
Method Detail

get

public double get(int index)
Description copied from interface: IRatings
Directly access ratings.

Specified by:
get in interface IRatings
Overrides:
get in class Ratings
Parameters:
index - the index of the rating
Returns:
the rating value

set

public double set(int index,
                  double rating)
Description copied from interface: IRatings
Directly access the ratings

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

get

public double get(int user_id,
                  int item_id)
Description copied from interface: IRatings
Directly access rating by user and item

Specified by:
get in interface IRatings
Overrides:
get in class Ratings
Parameters:
user_id - the user ID
item_id - the item ID
Returns:
the rating value for the given user and item

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 StaticRatings
Parameters:
user_id - the user ID
item_id - the item ID
rating - the rating value

add

public void add(int user_id,
                int item_id,
                byte rating)
Description copied from interface: IRatings
Add byte-valued rating to the collection.

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

tryGet

public java.lang.Double tryGet(int user_id,
                               int item_id)
Description copied from interface: IRatings
Try to retrieve a rating for a given user-item combination.

Specified by:
tryGet in interface IRatings
Overrides:
tryGet in class Ratings
Parameters:
user_id - the user ID
item_id - the item ID
Returns:
the first rating encountered that matches the user ID and item ID, or null if none is found

get

public double get(int user_id,
                  int item_id,
                  IntCollection indexes)
Description copied from interface: IRatings
Directly access rating by user and item.

Specified by:
get in interface IRatings
Overrides:
get in class Ratings
Parameters:
user_id - the user ID
item_id - the item ID
indexes - the indexes to look at
Returns:
the first rating encountered that matches the user ID and item ID

tryGet

public java.lang.Double tryGet(int user_id,
                               int item_id,
                               IntCollection indexes)
Description copied from interface: IRatings
Try to retrieve a rating for a given user-item combination.

Specified by:
tryGet in interface IRatings
Overrides:
tryGet in class Ratings
Parameters:
user_id - the user ID
item_id - the item ID
indexes - the indexes to look at
Returns:
the first rating encountered that matches the user ID and item ID, or null if none found