Created
August 5, 2015 20:06
-
-
Save stuarthalloway/c216188a17bb0f09701c to your computer and use it in GitHub Desktop.
Information about Datomic log ts
This file contains 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
;; This program walks the entire log extracting information about t | |
;; Does not reveal any domain data. | |
;; Scans entire log, so run against a backup instead of production if possible! | |
(require '[datomic.api :as d] | |
'[clojure.pprint :as pp]) | |
(defn max-t | |
"Returns the maximum t mentioned in a collection of datoms" | |
[datoms] | |
(reduce | |
(fn [n datom] | |
(max n (d/tx->t (:e datom)) (d/tx->t (:tx datom)))) | |
0 | |
datoms)) | |
(defn log-ts* | |
[conn n] | |
(let [log (d/log conn)] | |
(->> (d/tx-range log n nil) | |
(partition 2 1) | |
(map (fn [[tx1 tx2]] | |
{:t1 (:t tx1) | |
:t1-next (max-t (:data tx1)) | |
:t2 (:t tx2)}))))) | |
(defn log-ts | |
[uri n] | |
(let [conn (d/connect uri)] | |
(binding [*print-length* nil] | |
(pp/pprint | |
(log-ts* conn n))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment