Skip to content

Instantly share code, notes, and snippets.

@alexy
Created October 6, 2010 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexy/613717 to your computer and use it in GitHub Desktop.
Save alexy/613717 to your computer and use it in GitHub Desktop.
(defn tokyo-read-reps [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 db)
r (when (.iterinit tc)
(loop [k (.iternext2 tc) res [] i 0]
(if (empty? k) res
(do (when (zero? (mod i 10000)) (err "."))
(recur (.iternext2 tc) (conj
res [k (:days (jiraph.tc/db-get db k))]) (inc i))))))]
(tc/db-close db)
(into {} r)))
@alexy
Copy link
Author

alexy commented Oct 6, 2010

import "clojure/protobuf/extensions.proto";
message Dailydoubles {
required string user = 1;
repeated Day days = 2 [(map) = true];

message Day {
required int32 key = 1;
repeated double val = 2;
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment