Created
August 23, 2012 17:05
-
-
Save daviesian/3438768 to your computer and use it in GitHub Desktop.
Datomic data test
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
(ns datomic-test.numbers | |
(:use [datomic.api :only [q db] :as d] | |
[clojure.pprint] | |
[datomic-test.datomic-helpers])) | |
(def uri "datomic:mem://numbers") | |
(d/create-database uri) | |
(def conn (d/connect uri)) | |
(def nums (repeatedly 5000 (fn [] {:x (rand 500) :y (rand 500)}))) | |
(def schema | |
[{:db/id #db/id [:db.part/db] | |
:db/ident :point/x | |
:db/valueType :db.type/double | |
:db/cardinality :db.cardinality/one | |
:db.install/_attribute :db.part/db} | |
{:db/id #db/id [:db.part/db] | |
:db/ident :point/y | |
:db/valueType :db.type/double | |
:db/cardinality :db.cardinality/one | |
:db.install/_attribute :db.part/db}]) | |
(try | |
@(d/transact conn schema) | |
(catch Exception e (pprint e))) | |
(try | |
@(d/transact conn (map (fn [{x :x y :y}] | |
{:db/id (d/tempid :db.part/user) | |
:point/x x | |
:point/y y}) nums)) | |
(catch Exception e (pprint e))) | |
(count (q '[:find ?x :where [?e :point/x ?x]] (db conn))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment