org.mymedialite.data
Class DataSet

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

public abstract class DataSet
extends java.lang.Object
implements IDataSet

Abstract dataset class that implements some common functions.


Field Summary
protected  java.util.List<IntList> byItem
          Rating indices organized by item
protected  java.util.List<IntList> byUser
          Rating indices organized by user
protected  IntList items
           
protected  int maxItemID
           
protected  int maxUserID
           
protected  IntList users
           
 
Constructor Summary
DataSet()
           
 
Method Summary
 IntList allItems()
           
 IntList allUsers()
           
 void buildItemIndices()
          Build the item indices.
 void buildRandomIndex()
          Build the random index.
 void buildUserIndices()
          Build the user indices.
 java.util.List<IntList> byItem()
          indices by item.
 java.util.List<IntList> byUser()
          indices by user.
 int getIndex(int user_id, int item_id)
          Get index for a given user and item.
 int getIndex(int user_id, int item_id, IntCollection indexes)
          Get index for given user and item.
 IntSet getItems(IntList indices)
          Get all items that are referenced by a given list of indices.
 IntSet getUsers(IntList indices)
          Get all users that are referenced by a given list of indices.
 IntList items()
           
 int maxItemID()
           
 int maxUserID()
           
 IntList randomIndex()
          get a randomly ordered list of all indices.
 int size()
           
 java.lang.Integer tryGetIndex(int user_id, int item_id)
          Try to get the index for given user and item.
 java.lang.Integer tryGetIndex(int user_id, int item_id, IntCollection indexes)
          Try to get the index for given user and item.
 IntList 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
removeItem, removeUser
 

Field Detail

users

protected IntList users

items

protected IntList items

maxUserID

protected int maxUserID

maxItemID

protected int maxItemID

byUser

protected java.util.List<IntList> byUser
Rating indices organized by user


byItem

protected java.util.List<IntList> byItem
Rating indices organized by item

Constructor Detail

DataSet

public DataSet()
Method Detail

users

public IntList users()
Specified by:
users in interface IDataSet
Returns:
the user entries.

items

public IntList items()
Specified by:
items in interface IDataSet
Returns:
the item entries.

size

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

maxUserID

public int maxUserID()
Specified by:
maxUserID in interface IDataSet
Returns:
the maximum user ID in the dataset.

maxItemID

public int maxItemID()
Specified by:
maxItemID in interface IDataSet
Returns:
the maximum item ID in the dataset.

byUser

public java.util.List<IntList> byUser()
Description copied from interface: IDataSet
indices by user. Should be implemented as a lazy data structure

Specified by:
byUser in interface IDataSet

byItem

public java.util.List<IntList> byItem()
Description copied from interface: IDataSet
indices by item. Should be implemented as a lazy data structure

Specified by:
byItem in interface IDataSet

randomIndex

public IntList randomIndex()
Description copied from interface: IDataSet
get a randomly ordered list of all indices. Should be implemented as a lazy data structure

Specified by:
randomIndex in interface IDataSet

allUsers

public IntList allUsers()
Specified by:
allUsers in interface IDataSet
Returns:
all user IDs in the dataset.

allItems

public IntList allItems()
Specified by:
allItems in interface IDataSet
Returns:
all item IDs in the dataset.

buildUserIndices

public void buildUserIndices()
Description copied from interface: IDataSet
Build the user indices.

Specified by:
buildUserIndices in interface IDataSet

buildItemIndices

public void buildItemIndices()
Description copied from interface: IDataSet
Build the item indices.

Specified by:
buildItemIndices in interface IDataSet

buildRandomIndex

public void buildRandomIndex()
Description copied from interface: IDataSet
Build the random index.

Specified by:
buildRandomIndex in interface IDataSet

getUsers

public IntSet getUsers(IntList indices)
Description copied from interface: IDataSet
Get all users that are referenced by a given list of indices.

Specified by:
getUsers in interface IDataSet
Parameters:
indices - the indices to take into account
Returns:
all users referenced by the list of indices

getItems

public IntSet getItems(IntList indices)
Description copied from interface: IDataSet
Get all items that are referenced by a given list of indices.

Specified by:
getItems in interface IDataSet
Parameters:
indices - the indices to take into account
Returns:
all items referenced by the list of indices

getIndex

public int getIndex(int user_id,
                    int item_id)
Description copied from interface: IDataSet
Get index for a given user and item.

Specified by:
getIndex in interface IDataSet
Parameters:
user_id - the user ID
item_id - the item ID
Returns:
the index of the first event encountered that matches the user ID and item ID

getIndex

public int getIndex(int user_id,
                    int item_id,
                    IntCollection indexes)
Description copied from interface: IDataSet
Get index for given user and item.

Specified by:
getIndex in interface IDataSet
Parameters:
user_id - the user ID
item_id - the item ID
indexes - the indexes to look at
Returns:
the index of the first event encountered that matches the user ID and item ID

tryGetIndex

public java.lang.Integer tryGetIndex(int user_id,
                                     int item_id)
Description copied from interface: IDataSet
Try to get the index for given user and item.

Specified by:
tryGetIndex in interface IDataSet
Parameters:
user_id - the user ID
item_id - the item ID
Returns:
the index of the first event encountered that matches the user ID and item ID or null, if not found

tryGetIndex

public java.lang.Integer tryGetIndex(int user_id,
                                     int item_id,
                                     IntCollection indexes)
Description copied from interface: IDataSet
Try to get the index for given user and item.

Specified by:
tryGetIndex in interface IDataSet
Parameters:
user_id - the user ID
item_id - the item ID
indexes - the indexes to look at
Returns:
the index of the first event encountered that matches the user ID and item ID or null, if not found