public class LenskitRecommenderEngineLoader
extends java.lang.Object
Load a pre-built recommender engine from a file.
Constructor and Description |
---|
LenskitRecommenderEngineLoader() |
Modifier and Type | Method and Description |
---|---|
LenskitRecommenderEngineLoader |
addConfiguration(LenskitConfiguration config)
Add a configuration to use when loading the configuration.
|
java.lang.ClassLoader |
getClassLoader()
Get the configured class loader.
|
LenskitRecommenderEngine |
load(java.io.File file)
Load a recommender from a file.
|
LenskitRecommenderEngine |
load(java.io.InputStream stream)
Load a recommender engine from an input stream.
|
LenskitRecommenderEngineLoader |
setClassLoader(java.lang.ClassLoader classLoader)
Set the class loader to use when reading the engine.
|
LenskitRecommenderEngineLoader |
setCompressionMode(CompressionMode comp)
Set the compression mode to use.
|
LenskitRecommenderEngineLoader |
setValidationMode(EngineValidationMode mode)
Set the validation mode for loading the recommender engine.
|
public java.lang.ClassLoader getClassLoader()
Get the configured class loader.
public LenskitRecommenderEngineLoader setClassLoader(java.lang.ClassLoader classLoader)
Set the class loader to use when reading the engine.
classLoader
- The class loader to use.public LenskitRecommenderEngineLoader addConfiguration(LenskitConfiguration config)
Add a configuration to use when loading the configuration. The loaded graph will be post-processed to add in components bound by this configuration. If the engine was saved with excluded configurations, then this method should be used to provide configurations to reinstate any objects excluded from the saved model. The loader will throw an exception if the loaded model has any unresolved placeholders.
config
- The configuration to add.public LenskitRecommenderEngineLoader setValidationMode(EngineValidationMode mode)
Set the validation mode for loading the recommender engine. The default mode is EngineValidationMode.IMMEDIATE
.
mode
- The validation mode.public LenskitRecommenderEngineLoader setCompressionMode(CompressionMode comp)
Set the compression mode to use. The default is CompressionMode.AUTO
.
comp
- The compression mode.public LenskitRecommenderEngine load(@WillClose java.io.InputStream stream) throws java.io.IOException, RecommenderConfigurationException
Load a recommender engine from an input stream.
Note: this method is only capable of auto-detecting gzip-compressed data. If the compression mode is CompressionMode.AUTO
, only gzip-compressed streams are supported. Set the compression mode manually if you are using XZ compression.
stream
- The input stream.java.io.IOException
- if there is an error reading the input data.RecommenderConfigurationException
- if there is a configuration error with the deserialized recommender or the configurations applied to it.public LenskitRecommenderEngine load(java.io.File file) throws java.io.IOException, RecommenderConfigurationException
Load a recommender from a file.
file
- The recommender model file to load.java.io.IOException
- if there is an error reading the input data.RecommenderConfigurationException
- if there is a configuration error with the deserialized recommender or the configurations applied to it.