-
-
Save terjesb/009a0aea47224cfcdabe to your computer and use it in GitHub Desktop.
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
(def conn (start-datomic! (str "datomic:mem://" (java.util.UUID/randomUUID)) (schema))) | |
(def data | |
[{:db/id (d/tempid :com.mdrogalis/people) | |
:user/name "Mike"} | |
{:db/id (d/tempid :com.mdrogalis/people) | |
:user/name "Dorrene"} | |
{:db/id (d/tempid :com.mdrogalis/people) | |
:user/name "Benti"} | |
{:db/id (d/tempid :com.mdrogalis/people) | |
:user/name "Derek"} | |
{:db/id (d/tempid :com.mdrogalis/people) | |
:user/name "Kristen"}]) | |
@(d/transact conn data) | |
(def db (d/db conn)) | |
(defn datoms-between | |
"Returns a reducible collection of datoms created | |
between the start and end dates in a single partition." | |
[db partition start end] | |
(let [start-e (d/entid-at db partition start) | |
end-e (d/entid-at db partition end)] | |
(->> (d/seek-datoms db :eavt start-e) | |
(r/take-while #(< (:e %) end-e))))) | |
(def tip (d/next-t db)) | |
(def partition-size 2) | |
(def partitions (take-while #(< % tip) (range 0 tip partition-size))) | |
(->> partitions | |
(map #(into [] (datoms-between db :com.mdrogalis/people % (+ % partition-size)))) | |
(filter seq)) | |
[[#datom[277076930200554 64 "Mike" 13194139534313 true] #datom[277076930200555 64 "Dorrene" 13194139534313 true]] | |
[#datom[277076930200556 64 "Benti" 13194139534313 true] #datom[277076930200557 64 "Derek" 13194139534313 true]] | |
[#datom[277076930200558 64 "Kristen" 13194139534313 true]]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment