diff --git a/src/tokyo_graph.clj b/src/tokyo_graph.clj index b8f592f..33c8e46 100644 --- a/src/tokyo_graph.clj +++ b/src/tokyo_graph.clj @@ -11,15 +11,24 @@ (doto System/err (.print (apply str args)) .flush)) (defn errln [ & args] (doto System/err (.println (apply str args)) .flush)) + -(defn tokyo-read-reps [db-pathname & [proto str-load?]] +;; NB replace by specific arities declarations +(defn tokyo-open [db-pathname & [proto str-load?]] (let [ proto (or proto Repliers) init-params (let [par {:path db-pathname :read-only true}] (if str-load? par (merge par {:dump protobuf-dump :load (partial protobuf-load proto)}))) db (tc/db-init init-params) - _ (tc/db-open db) + _ (tc/db-open db)] + db)) + + +(defn tokyo-read-reps [db-pathname & db-args] + (let [ + ;; how do we just take all args from ourselves and pass into tokyo-open? + db (tokyo-open db-pathname db-args) tc (:db db) r (when (.iterinit tc) (loop [k (.iternext2 tc) res [] i 0] @@ -30,6 +39,12 @@ (tc/db-close db) (into {} r))) + +(defn tokyo-lookup [db user] + (let [tc (:db db)] + (:days (jiraph.tc/db-get db k)))) + + (defstruct id-chunk :id :chunk) (defn do-chunk [{:keys [id _]} proto chunk & [progress]] @@ -150,4 +165,4 @@ (finally (tc/db-close in-db) - (tc/db-close out-db))))) \ No newline at end of file + (tc/db-close out-db))))) diff --git a/src/ucap.clj b/src/ucap.clj index de66f75..983e319 100644 --- a/src/ucap.clj +++ b/src/ucap.clj @@ -1,7 +1,8 @@ (ns sc) (def dreps-path "/opt/data/twitter/tokyo/dreps.clb") -(let [[a b] (load-graphs dreps-path)] (def dreps a) (def dments b)) +(time (let [[a b] (load-graphs dreps-path)] (def dreps a) (def dments b))) +(time (def sgraph (soc-run dreps dments))) (def ustats (:ustats sgraph)) (time (def ucap (->> ustats (map (fn [[user {:keys [soc]}]] [user soc])) (sort-by second >))))