org.apache.mahout.cf.taste.impl.model
Class AbstractJDBCIDMigrator
java.lang.Object
org.apache.mahout.cf.taste.impl.model.AbstractIDMigrator
org.apache.mahout.cf.taste.impl.model.AbstractJDBCIDMigrator
- All Implemented Interfaces:
- IDMigrator
- Direct Known Subclasses:
- MySQLJDBCIDMigrator
public abstract class AbstractJDBCIDMigrator
- extends AbstractIDMigrator
Implementation which stores the reverse long-to-String mapping in a database. Subclasses can override and
configure the class to operate with particular databases by supplying appropriate SQL statements to the
constructor.
Constructor Summary |
protected |
AbstractJDBCIDMigrator(javax.sql.DataSource dataSource,
java.lang.String getStringIDSQL,
java.lang.String storeMappingSQL)
|
Method Summary |
void |
storeMapping(long longID,
java.lang.String stringID)
Stores the reverse long-to-String mapping in some kind of backing store. |
java.lang.String |
toStringID(long longID)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT_MAPPING_TABLE
public static final java.lang.String DEFAULT_MAPPING_TABLE
- See Also:
- Constant Field Values
DEFAULT_LONG_ID_COLUMN
public static final java.lang.String DEFAULT_LONG_ID_COLUMN
- See Also:
- Constant Field Values
DEFAULT_STRING_ID_COLUMN
public static final java.lang.String DEFAULT_STRING_ID_COLUMN
- See Also:
- Constant Field Values
AbstractJDBCIDMigrator
protected AbstractJDBCIDMigrator(javax.sql.DataSource dataSource,
java.lang.String getStringIDSQL,
java.lang.String storeMappingSQL)
- Parameters:
getStringIDSQL
- SQL statement which selects one column, the String ID, from a mapping table. The statement
should take one long parameter.storeMappingSQL
- SQL statement which saves a mapping from long to String. It should take two parameters, a long
and a String.
storeMapping
public final void storeMapping(long longID,
java.lang.String stringID)
throws TasteException
- Description copied from interface:
IDMigrator
- Stores the reverse long-to-String mapping in some kind of backing store. Note that this must be called
directly (or indirectly through
IDMigrator.initialize(Iterable)
) for every String that might be encountered
in the application, or else the mapping will not be known.
- Parameters:
longID
- long IDstringID
- string ID that maps to/from that long ID
- Throws:
TasteException
- if an error occurs while saving the mapping
toStringID
public final java.lang.String toStringID(long longID)
throws TasteException
- Returns:
- the string ID most recently associated with the given long ID, or null if doesn't exist
- Throws:
TasteException
- if an error occurs while retrieving the mapping
Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.