Asami Demo 001

Links: https://clojars.org/org.clojars.quoll/asami

https://cljdoc.org/d/org.clojars.quoll/asami/0.4.9/doc/introduction-to-asami

https://dev.to/quoll/asami-3fi7

https://github.com/threatgrid/asami

https://clojars.org/cheshire

https://github.com/dakrone/cheshire

https://bauerspace.com/library-cheshire/

{:deps {org.clojure/clojure {:mvn/version "1.10.1"}
        ;; complient is used for autocompletion
        ;; add your libs here (and restart the runtime to pick up changes)
        compliment/compliment {:mvn/version "0.3.9"}
        org.clojars.quoll/asami {:mvn/version "2.0.5"}
        ;; NOTE: "cheshire/cheshire" as written on Clojars did not work here in this context... Question: Why? 
        cheshire {:mvn/version "5.10.0"}
        }}
deps.edn
Extensible Data Notation
{:hello (clojure-version)}
0.1s
Clojure

Import the necessary libaries

(require '[asami.core :as d])
(require '[cheshire.core :as json])
11.8s
Clojure
(def conn (d/connect "asami:local://tmpdata"))
(def d (json/parse-string (slurp "/Users/pgearon/tmp/data/cb.json")))
0.3s
Clojure
(count d)
Clojure
(first d)
Clojure
(def tx @(d/transact conn {:tx-data d}))
Clojure
(count (:tx-data tx))
Clojure

Heading

(def db (d/db conn))
(d/q '[:find (count ?e) . :where [?e :tg/entity true]] db)
(d/q '[:find (count ?a) . :where [?e ?a ?v]] db)
(d/q '[:find (count ?a) . :where [?e ?a ?v]] conn)
Clojure
(pprint (d/q '[:find [?a ...] :where [?e ?a ?v]] db))
(d/q '[:find [?v ...] :where [?e "frame" ?v]] db)
(->> (d/q '[:find [?v ...] :where [?e "frame" ?v]] db)
     (take 2)
     (map #(d/entity db %))
     pprint)
Clojure
(def bundle-dir (io/file "/Users/pgearon/dev/iroh-engine/resources/data/bundle"))
(def bundles (map (comp json/parse-stream io/reader) (.listFiles bundle-dir)))
(def tx2 @(d/transact conn {:tx-data bundles}))
(count (:tx-data tx2))
Clojure
(def db2 (d/db conn))
(d/q '[:find (count ?e) . :where [?e :tg/entity true]] db2)
(d/q '[:find (count ?a) . :where [?e ?a ?v]] db2)
Clojure
Runtimes (1)