Skip to content

Instantly share code, notes, and snippets.

@llasram
Created October 21, 2013 08:59
Show Gist options
  • Save llasram/7080761 to your computer and use it in GitHub Desktop.
Save llasram/7080761 to your computer and use it in GitHub Desktop.
LensKit precalculation dependency-injection structure.
(ns ...
(:import [clojure.lang IDeref]
...)
(definterface UUPrecalc)
(defprovider uu-precalc
^UUPrecalc [^UserDAO udao, ^UserEventDAO uedao]
(let [data ...]
(reify UUPrecalc IDeref (deref [_] data))))
...
(defprovider suu-item-scorer
^ItemScorer [^UserEventDAO udao, ^ItemEventDAO idao, ^UUPrecalc precalc]
;; Use @precalc
...)
...
(defn configure-recommender
...
(-> (.bind UUPrecalc) (.toProvider uu-precalc))
...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment