/** * Build the recommender directly, skipping an engine. This does not separate the recommender from * the DAO, it just directly builds it. * * @param dao The data access object to use. Can be `null` to build without a DAO, but this is only useful in * special cases. * @return The built recommender engine, with {@linkplain ModelDisposition#EXCLUDED excluded} * components removed. * @throws RecommenderBuildException if there is an error building the engine. */ public LenskitRecommender buildRecommender(DataAccessObject dao) throws RecommenderBuildException { DAGNode<Component, Dependency> graph = buildRecommenderGraph(dao); graph = instantiateGraph(graph); return new LenskitRecommender(graph); }
@Override protected DAGNode<Component, Dependency> instantiateGraph(DAGNode<Component, Dependency> graph) { if (cache == null) { logger.debug("Building directly without a cache"); return super.instantiateGraph(graph); } else { logger.debug("Instantiating graph with a cache"); try { Set<DAGNode<Component, Dependency>> nodes = GraphtUtils.getShareableNodes(graph); logger.debug("resolving {} nodes", nodes.size()); DAGNode<Component, Dependency> newGraph = NodeProcessors.processNodes(graph, nodes, cache); logger.debug("newGraph went from {} to {} nodes", newGraph.getReachableNodes().size(), newGraph.getReachableNodes().size()); return newGraph; } catch (InjectionException e) { logger.error("Error instantiating recommender nodes with cache", e); throw new RecommenderBuildException("Cached instantiation failed", e); } } } }
/** * Build the recommender engine. * * @param dao The data access object to use. Can be `null` to build without a DAO, but this is only useful in * special cases. * @return The built recommender engine, with {@linkplain ModelDisposition#EXCLUDED excluded} * components removed. * @throws RecommenderBuildException if there is an error building the engine. */ public LenskitRecommenderEngine build(DataAccessObject dao) throws RecommenderBuildException { DAGNode<Component, Dependency> graph = buildRecommenderGraph(dao); graph = instantiateGraph(graph); graph = rewriteExcludedComponents(graph, dao); boolean instantiable = GraphtUtils.getPlaceholderNodes(graph).isEmpty(); return new LenskitRecommenderEngine(graph, instantiable); }
/** * Build the recommender directly, skipping an engine. This does not separate the recommender from * the DAO, it just directly builds it. * * @param dao The data access object to use. Can be `null` to build without a DAO, but this is only useful in * special cases. * @return The built recommender engine, with {@linkplain ModelDisposition#EXCLUDED excluded} * components removed. * @throws RecommenderBuildException if there is an error building the engine. */ public LenskitRecommender buildRecommender(DataAccessObject dao) throws RecommenderBuildException { DAGNode<Component, Dependency> graph = buildRecommenderGraph(dao); graph = instantiateGraph(graph); return new LenskitRecommender(graph); }
/** * Build the recommender engine. * * @param dao The data access object to use. Can be `null` to build without a DAO, but this is only useful in * special cases. * @return The built recommender engine, with {@linkplain ModelDisposition#EXCLUDED excluded} * components removed. * @throws RecommenderBuildException if there is an error building the engine. */ public LenskitRecommenderEngine build(DataAccessObject dao) throws RecommenderBuildException { DAGNode<Component, Dependency> graph = buildRecommenderGraph(dao); graph = instantiateGraph(graph); graph = rewriteExcludedComponents(graph, dao); boolean instantiable = GraphtUtils.getPlaceholderNodes(graph).isEmpty(); return new LenskitRecommenderEngine(graph, instantiable); }