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:
Serializable, 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.

See Also:
Serialized Form

Field Summary
static String DATA_SOURCE_KEY
           
static String GET_ALL_USERS_SQL_KEY
           
static String GET_ITEMS_SQL_KEY
           
static String GET_MAX_PREFERENCE_KEY
           
static String GET_MIN_PREFERENCE_KEY
           
static String GET_NUM_ITEMS_SQL_KEY
           
static String GET_NUM_PREFERENCE_FOR_ITEM_KEY
           
static String GET_NUM_PREFERENCE_FOR_ITEMS_KEY
           
static String GET_NUM_USERS_SQL_KEY
           
static String GET_PREFERENCE_SQL_KEY
           
static String GET_PREFERENCE_TIME_SQL_KEY
           
static String GET_PREFS_FOR_ITEM_SQL_KEY
           
static String GET_USER_SQL_KEY
           
static String GET_USERS_SQL_KEY
           
static String REMOVE_PREFERENCE_SQL_KEY
           
static 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_PREFERENCE_TIME_COLUMN, DEFAULT_USER_ID_COLUMN
 
Fields inherited from class org.apache.mahout.cf.taste.impl.common.jdbc.AbstractJDBCComponent
DEFAULT_DATASOURCE_NAME
 
Constructor Summary
GenericJDBCDataModel(File propertiesFile)
           See GenericJDBCDataModel(Properties).
GenericJDBCDataModel(Properties props)
           Specifies all SQL queries in a Properties object.
GenericJDBCDataModel(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, getMaxPreference, getMinPreference, getNumItems, getNumUsers, getNumUsersWithPreferenceFor, getNumUsersWithPreferenceFor, getPreferenceColumn, getPreferencesForItem, getPreferencesFromUser, getPreferenceTable, getPreferenceTime, getPreferenceValue, getUserIDColumn, getUserIDs, hasPreferenceValues, refresh, removePreference, setLongParameter, setPreference
 
Methods inherited from class org.apache.mahout.cf.taste.impl.common.jdbc.AbstractJDBCComponent
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 String DATA_SOURCE_KEY
See Also:
Constant Field Values

GET_PREFERENCE_SQL_KEY

public static final String GET_PREFERENCE_SQL_KEY
See Also:
Constant Field Values

GET_PREFERENCE_TIME_SQL_KEY

public static final String GET_PREFERENCE_TIME_SQL_KEY
See Also:
Constant Field Values

GET_USER_SQL_KEY

public static final String GET_USER_SQL_KEY
See Also:
Constant Field Values

GET_ALL_USERS_SQL_KEY

public static final String GET_ALL_USERS_SQL_KEY
See Also:
Constant Field Values

GET_NUM_USERS_SQL_KEY

public static final String GET_NUM_USERS_SQL_KEY
See Also:
Constant Field Values

GET_NUM_ITEMS_SQL_KEY

public static final String GET_NUM_ITEMS_SQL_KEY
See Also:
Constant Field Values

SET_PREFERENCE_SQL_KEY

public static final String SET_PREFERENCE_SQL_KEY
See Also:
Constant Field Values

REMOVE_PREFERENCE_SQL_KEY

public static final String REMOVE_PREFERENCE_SQL_KEY
See Also:
Constant Field Values

GET_USERS_SQL_KEY

public static final String GET_USERS_SQL_KEY
See Also:
Constant Field Values

GET_ITEMS_SQL_KEY

public static final String GET_ITEMS_SQL_KEY
See Also:
Constant Field Values

GET_PREFS_FOR_ITEM_SQL_KEY

public static final String GET_PREFS_FOR_ITEM_SQL_KEY
See Also:
Constant Field Values

GET_NUM_PREFERENCE_FOR_ITEM_KEY

public static final String GET_NUM_PREFERENCE_FOR_ITEM_KEY
See Also:
Constant Field Values

GET_NUM_PREFERENCE_FOR_ITEMS_KEY

public static final String GET_NUM_PREFERENCE_FOR_ITEMS_KEY
See Also:
Constant Field Values

GET_MAX_PREFERENCE_KEY

public static final String GET_MAX_PREFERENCE_KEY
See Also:
Constant Field Values

GET_MIN_PREFERENCE_KEY

public static final String GET_MIN_PREFERENCE_KEY
See Also:
Constant Field Values
Constructor Detail

GenericJDBCDataModel

public GenericJDBCDataModel(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(File propertiesFile)
                     throws TasteException

See GenericJDBCDataModel(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(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–2014 The Apache Software Foundation. All rights reserved.