org.apache.mahout.cf.taste.impl.model.jdbc
Class GenericJDBCDataModel

java.lang.Object
  extended by org.apache.mahout.cf.taste.impl.common.jdbc.AbstractJDBCComponent
      extended by org.apache.mahout.cf.taste.impl.model.jdbc.AbstractJDBCDataModel
          extended by org.apache.mahout.cf.taste.impl.model.jdbc.GenericJDBCDataModel
All Implemented Interfaces:
Refreshable, DataModel, JDBCDataModel

public final class GenericJDBCDataModel
extends AbstractJDBCDataModel

A generic DataModel designed for use with other JDBC data sources; one just specifies all necessary SQL queries to the constructor here. Optionally, the queries can be specified from a Properties object, File, or InputStream. This class is most appropriate when other existing implementations of AbstractJDBCDataModel are not suitable. If you are using this class to support a major database, consider contributing a specialized implementation of AbstractJDBCDataModel to the project for this database.


Field Summary
static java.lang.String DATA_SOURCE_KEY
           
static java.lang.String GET_ALL_USERS_SQL_KEY
           
static java.lang.String GET_ITEMS_SQL_KEY
           
static java.lang.String GET_NUM_ITEMS_SQL_KEY
           
static java.lang.String GET_NUM_PREFERENCE_FOR_ITEM_KEY
           
static java.lang.String GET_NUM_PREFERENCE_FOR_ITEMS_KEY
           
static java.lang.String GET_NUM_USERS_SQL_KEY
           
static java.lang.String GET_PREFERENCE_SQL_KEY
           
static java.lang.String GET_PREFS_FOR_ITEM_SQL_KEY
           
static java.lang.String GET_USER_SQL_KEY
           
static java.lang.String GET_USERS_SQL_KEY
           
static java.lang.String REMOVE_PREFERENCE_SQL_KEY
           
static java.lang.String SET_PREFERENCE_SQL_KEY
           
 
Fields inherited from class org.apache.mahout.cf.taste.impl.model.jdbc.AbstractJDBCDataModel
DEFAULT_ITEM_ID_COLUMN, DEFAULT_PREFERENCE_COLUMN, DEFAULT_PREFERENCE_TABLE, DEFAULT_USER_ID_COLUMN
 
Fields inherited from class org.apache.mahout.cf.taste.impl.common.jdbc.AbstractJDBCComponent
DEFAULT_DATASOURCE_NAME
 
Constructor Summary
GenericJDBCDataModel(java.io.File propertiesFile)
           See GenericJDBCDataModel(java.util.Properties).
GenericJDBCDataModel(java.util.Properties props)
           Specifies all SQL queries in a Properties object.
GenericJDBCDataModel(java.lang.String resourcePath)
           See GenericJDBCDataModel(Properties).
 
Method Summary
 
Methods inherited from class org.apache.mahout.cf.taste.impl.model.jdbc.AbstractJDBCDataModel
buildPreference, doGetPreferencesForItem, exportWithIDsOnly, exportWithPrefs, getDataSource, getItemIDColumn, getItemIDs, getItemIDsFromUser, getLongColumn, getNumItems, getNumUsers, getNumUsersWithPreferenceFor, getPreferenceColumn, getPreferencesForItem, getPreferencesFromUser, getPreferenceTable, getPreferenceValue, getUserIDColumn, getUserIDs, hasPreferenceValues, refresh, removePreference, setLongParameter, setPreference
 
Methods inherited from class org.apache.mahout.cf.taste.impl.common.jdbc.AbstractJDBCComponent
advanceResultSet, checkNotNullAndLog, checkNotNullAndLog, getFetchSize, lookupDataSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATA_SOURCE_KEY

public static final java.lang.String DATA_SOURCE_KEY
See Also:
Constant Field Values

GET_PREFERENCE_SQL_KEY

public static final java.lang.String GET_PREFERENCE_SQL_KEY
See Also:
Constant Field Values

GET_USER_SQL_KEY

public static final java.lang.String GET_USER_SQL_KEY
See Also:
Constant Field Values

GET_ALL_USERS_SQL_KEY

public static final java.lang.String GET_ALL_USERS_SQL_KEY
See Also:
Constant Field Values

GET_NUM_USERS_SQL_KEY

public static final java.lang.String GET_NUM_USERS_SQL_KEY
See Also:
Constant Field Values

GET_NUM_ITEMS_SQL_KEY

public static final java.lang.String GET_NUM_ITEMS_SQL_KEY
See Also:
Constant Field Values

SET_PREFERENCE_SQL_KEY

public static final java.lang.String SET_PREFERENCE_SQL_KEY
See Also:
Constant Field Values

REMOVE_PREFERENCE_SQL_KEY

public static final java.lang.String REMOVE_PREFERENCE_SQL_KEY
See Also:
Constant Field Values

GET_USERS_SQL_KEY

public static final java.lang.String GET_USERS_SQL_KEY
See Also:
Constant Field Values

GET_ITEMS_SQL_KEY

public static final java.lang.String GET_ITEMS_SQL_KEY
See Also:
Constant Field Values

GET_PREFS_FOR_ITEM_SQL_KEY

public static final java.lang.String GET_PREFS_FOR_ITEM_SQL_KEY
See Also:
Constant Field Values

GET_NUM_PREFERENCE_FOR_ITEM_KEY

public static final java.lang.String GET_NUM_PREFERENCE_FOR_ITEM_KEY
See Also:
Constant Field Values

GET_NUM_PREFERENCE_FOR_ITEMS_KEY

public static final java.lang.String GET_NUM_PREFERENCE_FOR_ITEMS_KEY
See Also:
Constant Field Values
Constructor Detail

GenericJDBCDataModel

public GenericJDBCDataModel(java.util.Properties props)
                     throws TasteException

Specifies all SQL queries in a Properties object. See the *_KEY constants in this class (e.g. GET_USER_SQL_KEY) for a list of all keys which must map to a value in this object.

Parameters:
props - Properties object containing values
Throws:
TasteException - if anything goes wrong during initialization

GenericJDBCDataModel

public GenericJDBCDataModel(java.io.File propertiesFile)
                     throws TasteException

See GenericJDBCDataModel(java.util.Properties). This constructor reads values from a file instead, as if with Properties.load(InputStream). So, the file should be in standard Java properties file format -- containing key=value pairs, one per line.

Parameters:
propertiesFile - properties file
Throws:
TasteException - if anything goes wrong during initialization

GenericJDBCDataModel

public GenericJDBCDataModel(java.lang.String resourcePath)
                     throws TasteException

See GenericJDBCDataModel(Properties). This constructor reads values from a resource available in the classpath, as if with Class.getResourceAsStream(String) and Properties.load(InputStream). This is useful if your configuration file is, for example, packaged in a JAR file that is in the classpath.

Parameters:
resourcePath - path to resource in classpath (e.g. "/com/foo/TasteSQLQueries.properties")
Throws:
TasteException - if anything goes wrong during initialization


Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.