Created
October 6, 2010 17:20
-
-
Save alexy/613717 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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;
}
}