A {@link DataModel} backed by a comma-delimited file. This class typically expects a file where eachline contains a user ID, followed by item ID, followed by preferences value, separated by commas. You may also use tabs.
The preference value is assumed to be parseable as a double
. The user and item IDs are ready literally as Strings and treated as such in the API. Note that this means that whitespace matters in the data file; they will be treated as part of the ID values.
This class will reload data from the data file when {@link #refresh(Collection)} is called, unlessthe file has been reloaded very recently already.
This class will also look for update "delta" files in the same directory, with file names that start the same way (up to the first period). These files should have the same format, and provide updated data that supersedes what is in the main data file. This is a mechanism that allows an application to push updates to {@link FileDataModel} without re-copying the entire data file.
The line may contain a blank preference value (e.g. "123,ABC,"). This is interpreted to mean "delete preference", and is only useful in the context of an update delta file (see above).
Finally, for application that have no notion of a preference value (that is, the user simply expresses a preference for an item, but no degree of preference), the caller can simply omit the third token in each line altogether -- for example, "123,ABC".
This class is not intended for use with very large amounts of data (over, say, tens of millions of rows). For that, a JDBC-backed {@link DataModel} and a database are more appropriate.
It is possible and likely useful to subclass this class and customize its behavior to accommodate application-specific needs and input formats. See {@link #processLine(String,Map,Map)}, {@link #buildItem(String)}, {@link #buildUser(String,List)}and {@link #buildPreference(User,Item,double)}.
|
|
|
|
|
|
|
|