netflix.algorithms.modelbased.reader
Class DataReaderFromMem

java.lang.Object
  extended by netflix.algorithms.modelbased.reader.DataReaderFromMem
All Implemented Interfaces:
DataReader

public class DataReaderFromMem
extends java.lang.Object
implements DataReader

A DataReader that reads in movies data from a serialized object


Constructor Summary
DataReaderFromMem(MemHelper memHelper)
           
 
Method Summary
 void close()
          Closes and does necessary clean-up
 double getAverageMovieRating(int mid)
          Gets the average rating for a particular movie
 double getAverageRatingForUser(int uid)
          Gets the average rating for a user
 java.util.ArrayList<Triple> getCommonMovieRatAndAve(int uid1, int uid2)
          Gets all the common movie ratings and average ratings for two users
 java.util.ArrayList<Pair> getCommonMovieRatings(int uid1, int uid2)
          Gets the ratings for common movies for two users
 java.util.ArrayList<Triple> getCommonUserRatAndAve(int mId1, int mId2)
          Gets the individual and average ratings for common users between two movies
 java.util.ArrayList<Pair> getCommonUserRatings(int mId1, int mId2)
          Gets the ratings for common users between two movies
 int getNumberOfMovies()
          Returns the number of movies
 int getNumberOfUsers()
          Returns the number of users
 int getRating(int uid, int mid)
          Get the rating for a user - movie pair
 int getRatingFromComposite(int composite)
          Gets the rating from a user-rating or movie-rating block (see movie MemHelper for more information)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataReaderFromMem

public DataReaderFromMem(MemHelper memHelper)
Method Detail

getNumberOfUsers

public int getNumberOfUsers()
Description copied from interface: DataReader
Returns the number of users

Specified by:
getNumberOfUsers in interface DataReader
Returns:
the number of users

getNumberOfMovies

public int getNumberOfMovies()
Description copied from interface: DataReader
Returns the number of movies

Specified by:
getNumberOfMovies in interface DataReader
Returns:
the number of movies

getRating

public int getRating(int uid,
                     int mid)
Description copied from interface: DataReader
Get the rating for a user - movie pair

Specified by:
getRating in interface DataReader
Parameters:
uid - User id
mid - Movie id
Returns:
rating for uid, mid

getCommonUserRatings

public java.util.ArrayList<Pair> getCommonUserRatings(int mId1,
                                                      int mId2)
Description copied from interface: DataReader
Gets the ratings for common users between two movies

Specified by:
getCommonUserRatings in interface DataReader
Returns:

getCommonUserRatAndAve

public java.util.ArrayList<Triple> getCommonUserRatAndAve(int mId1,
                                                          int mId2)
Description copied from interface: DataReader
Gets the individual and average ratings for common users between two movies

Specified by:
getCommonUserRatAndAve in interface DataReader
Returns:

getRatingFromComposite

public int getRatingFromComposite(int composite)
Description copied from interface: DataReader
Gets the rating from a user-rating or movie-rating block (see movie MemHelper for more information)

Specified by:
getRatingFromComposite in interface DataReader
Returns:

getAverageMovieRating

public double getAverageMovieRating(int mid)
Description copied from interface: DataReader
Gets the average rating for a particular movie

Specified by:
getAverageMovieRating in interface DataReader
Returns:

close

public void close()
Description copied from interface: DataReader
Closes and does necessary clean-up

Specified by:
close in interface DataReader

getCommonMovieRatings

public java.util.ArrayList<Pair> getCommonMovieRatings(int uid1,
                                                       int uid2)
Description copied from interface: DataReader
Gets the ratings for common movies for two users

Specified by:
getCommonMovieRatings in interface DataReader
Parameters:
uid1 - - id of one of the users
uid2 - - the other user's id
Returns:
- list with the ratings in the form

getAverageRatingForUser

public double getAverageRatingForUser(int uid)
Description copied from interface: DataReader
Gets the average rating for a user

Specified by:
getAverageRatingForUser in interface DataReader
Parameters:
uid - - the id of the user
Returns:
- the user's average rating

getCommonMovieRatAndAve

public java.util.ArrayList<Triple> getCommonMovieRatAndAve(int uid1,
                                                           int uid2)
Description copied from interface: DataReader
Gets all the common movie ratings and average ratings for two users

Specified by:
getCommonMovieRatAndAve in interface DataReader
Parameters:
uid1 - - id of one of the users
uid2 - - id of the other user
Returns:
- list where each entry is