Slide 1

Slide 1 text

EXPLORING DATOMIC PUG/IP - 2014.02.10 JAMES POLERA [ @UNCRYPTIC ] [ HTTP://BITZERO.ORG ] [email protected]

Slide 2

Slide 2 text

About Me My name is James Polera, I'm the IT manager for a mid-size law firm in Union county, and part of the sister technology company (they do .NET primarily). I also own a consulting company where I do contract work in my spare time. I've been working in IT professionally since 2000 in both Sysadmin and Developer roles (often at the SAME TIME). I’ve been participating as an organizer for PUG/IP since late 2012. I like to call myself an autodidactic polyglot.

Slide 3

Slide 3 text

ON TO DATOMIC

Slide 4

Slide 4 text

What isn’t Datomic? Open Source SQL NoSQL Update in place

Slide 5

Slide 5 text

What is Datomic? Fact storage Not just that - accretive fact storage “NewSQL” Free* Commercially supported by Cognitect (Pro version)

Slide 6

Slide 6 text

Datomic Components Peer library Transactor Storage (memory, local, advanced)

Slide 7

Slide 7 text

The Peer Library Is embedded in your application Provides: data access, querying and caching Talks to the transactor Speaks Datalog (more on that later)

Slide 8

Slide 8 text

The Peer Library Is JVM based (supported on Java and Clojure) Is accessible via a REST API for non-JVM languages *Really* tricky to get working with Jython (also buggy due to an apparent implementation issue in Jython) - https://groups.google.com/forum/#!msg/ datomic/b8iODxDmmvM/OowdRu6oQ2wJ

Slide 9

Slide 9 text

The Transactor Manages transactions and changes to your data Your writes go through here Your deletions (or retractions) go through here

Slide 10

Slide 10 text

The Storage Service Available for Pro only Can be: Dynamo DB Riak Couchbase Infinispan SQL

Slide 11

Slide 11 text

Feature matrix Datomic Free Datomic Pro Starter Datomic Pro Embedded Datalog Engine Yes Yes Yes Embedded Memory Database Yes Yes Yes Transactor-local Storage Yes Yes Yes Acid Transactions Yes Yes Yes Advanced Storage Service No Yes Yes Datomic Console Yes Yes Yes High Availability Transactor No Yes Yes Integrated memcached No Yes Yes Number of Processes 2 peers + transactor 2 peers + transactor Licensed Limit Redistributable Yes No No (OEM Available) License Free Free (with registration) Paid, perpetual Support Community Community Included w/maintenance Data from http://www.datomic.com/pricing.html

Slide 12

Slide 12 text

LET’S TALK DATA

Slide 13

Slide 13 text

But first, some basics: Datom Entity Attribute Value Transaction James Likes Coffee 2014-02-10T18:30:00

Slide 14

Slide 14 text

But first, some basics: Datom Datoms are immutable Datomic has no concept of “UPDATE Users SET Username=‘somenewname’ where UserId=42;” At this point in time UserId 42 has ‘somename’ If that changes, Datomic retains the old data, but moves the new data to the top.

Slide 15

Slide 15 text

But first, some basics: Datalog It’s older than Datomic (Datomic has an implementation of Datalog) Has roots in Prolog It’s embedded …which means your queries happen locally

Slide 16

Slide 16 text

Datalog Datomic’s Datalog deals in sets of tuples of the form [Entity Attribute Value Transaction] http://www.learndatalogtoday.org/

Slide 17

Slide 17 text

OK, REALLY LET’S TALK DATA

Slide 18

Slide 18 text

Extensible Data Notion (EDN) Schemas are defined using EDN Sample schema: tvdb-schema.edn

Slide 19

Slide 19 text

LET’S CONNECT TO DATOMIC

Slide 20

Slide 20 text

The Transactor Start it up from your Datomic directory with “bin/ transactor config/samples/dev-transactor- template.properties”

Slide 21

Slide 21 text

The Java Shell Start it up from your Datomic directory with “bin/ shell” Let’s setup our database.

Slide 22

Slide 22 text

The Datomic Console Start it up from your Datomic directory with “bin/ console -p ” i.e. “bin/console -p 8899 free “datomic:free// localhost:4334/“ Point your web browser to http://localhost:8899/ browse

Slide 23

Slide 23 text

Anatomy of a Datalog Query Let’s get all of our shows (should only be 1 at this point) [:find ?shows :where [?s :show/name ?shows]]

Slide 24

Slide 24 text

Anatomy of a Datalog Query What about passing parameters? [:find ?shows :in $ ?name :where [?p :person/name ?name] [?s :show/actors ?p] [?s :show/name ?shows]]

Slide 25

Slide 25 text

Anatomy of a Datalog Query What about filtering in the query? (with a little bit of Clojure) [:find ?shows :in $ ?name :where [?p :person/name ?name] [?s :show/actors ?p] [?s :show/name ?shows] [(.startsWith ?shows "D")]]

Slide 26

Slide 26 text

Accessing from Python Using the REST interface Start it up with: bin/rest -p 8080 free “datomic:free://localhost:4334/“ https://github.com/tony-landis/datomic-py To the IPython Notebook!

Slide 27

Slide 27 text

Resources http://www.learndatalogtoday.org/ https://github.com/edn-format/edn http://docs.datomic.com/ http://www.infoq.com/articles/Architecture- Datomic https://github.com/tony-landis/datomic-py

Slide 28

Slide 28 text

Resources My Datomic playlist - http://www.youtube.com/ playlist? list=PLazWoTyz1FjpswrAVKyTenxq9ALO4Yg0y https://github.com/polera/exploring_datomic

Slide 29

Slide 29 text

THANK YOU