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
<script src="https://github.com/tonsky/datascript/releases/download/0.18.2/datascript-0.18.2.min.js"></script> | |
<script type="text/javascript"> | |
const d = datascript; | |
const schema = { | |
"db/ident": {":db/unique": ":db.unique/identity"}, | |
"operator/name": {":db/cardinality": ":db.cardinality/one"}, | |
"operator/address": {":db/unique": ":db.unique/identity"}, |
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
#[macro_use] | |
extern crate abomonation_derive; | |
extern crate abomonation; | |
extern crate timely; | |
extern crate differential_dataflow; | |
use std::fs::File; | |
use std::io::{BufRead,BufReader}; | |
use timely::dataflow::*; |
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
;; the BTset namespace needs has to be extended by the | |
;; following helper | |
(defn iter-seek | |
"Returns iterator for all X where key-from <= X." | |
[^Iter iter key-from] | |
(let [path (-seek (.-set iter) key-from)] | |
(when-not (neg? path) | |
(Iter. (.-set iter) path (.-right iter) (keys-for (.-set iter) path) (path-get path 0))))) |
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
(s/def :db/id (s/with-gen number? #(gen/fmap (fn [_] (clojure.lang.RT/nextID)) (gen/int)))) | |
(s/def :entity/name (s/and string? #(< 3 (count %) 10))) | |
(s/def :entity/shareholder :db/id) | |
(s/def :person/id (s/with-gen string? #(s/gen #{"Alice" "Bob" "Eve" "Mabel" "Dipper"}))) | |
(s/def :person/alias :db/id) | |
(s/def :company/name (s/with-gen string? #(s/gen #{"Alice" "Bob" "Eve" "Mabel" "Dipper"}))) | |
(s/def :company/subsidiary :db/id) |
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
(def encode-symbol (memoize (fn [sym] (clojure.lang.RT/nextID)))) |
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
;; RGA | |
;; https://speakerdeck.com/ept/data-structures-as-queries-expressing-crdts-using-datalog?slide=22 | |
(def schema | |
{:id/node {:db/valueType :Number} | |
:id/ctr {:db/valueType :Number} | |
:insert/id {:db/valueType :Eid} | |
:insert/parent {:db/valueType :Eid} | |
:assign/id {:db/valueType :Eid} | |
:assign/elem {:db/valueType :Eid} |
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
;; LWW Register | |
;; https://speakerdeck.com/ept/data-structures-as-queries-expressing-crdts-using-datalog?slide=15 | |
(def schema | |
{:assign/time {:db/valueType :Number} | |
:assign/key {:db/valueType :Number} | |
:assign/value {:db/valueType :Number}}) | |
(def rules | |
'[[(older ?t1 ?key) |
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
{:deps | |
{org.clojure/clojure {:mvn/version "1.9.0"} | |
com.datomic/datomic-free {:mvn/version "0.9.5697"}}} |
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
(require '[datomic.api :as d]) | |
(def uri "datomic:mem://policing") | |
(d/create-database uri) | |
(def conn (d/connect uri)) | |
;; We are managing classified documents. | |
(def schema | |
[{:db/ident :level/rank |
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
// | |
// Usage | |
// | |
// where before you might've had: | |
// const selection = parent.selectAll('li').data(data, keyFn) | |
// | |
// you now have: | |
const selection = diff(parent.selectAll('li'), data, keyFn) |
NewerOlder