Giter Site home page Giter Site logo

clj-3df's Introduction

clj-3df

Clojars Project

This is alpha-quality software, not feature-complete, and not yet ready for use in production services.

3DF is best thought of as a pub/sub system in which subscriptions can be arbitrary Datalog expressions. Subscribers register queries with the broker, and data sources (such as Kafka, Datomic, or any other source-of-truth) publish new data to it. All subscriber queries affected by incoming data will be notified with a diff, describing how their results have changed. The Datalog implementation is modeled after Datomic's query language and aims to support the same set of features.

3DF does this efficiently, thanks to being built on top of differential dataflows. In particular, Differential Dataflow will only compute changes, rather than execute a computation from scratch.

This repository contains the Clojure client for 3DF. The broker is written in Rust and can be found in the Declarative Differential Dataflows repository.

How it works

The 3DF client compiles Datalog expressions into an intermediate representation that can be synthesised into a differential dataflow on the server. This dataflow is then registered and executed across any number of workers. Whenever query results change due to new data entering the system, the server will push the neccessary changes via a WebSocket connection.

For example, consider a subscriber created the following subscription:

(exec! conn
  (query db "user inbox" 
    '[:find ?msg ?content
      :where 
      [?msg :msg/recipient "[email protected]"]
      [?msg :msg/content ?content]]))

and a new message arrives in the system.

[{:msg/receipient "[email protected]"
  :msg/content    "Hello!"}]

Then the server will push the following results to the subscriber:

[[[<msg-id> "Hello!"] +1]]

If at some later point in time, this message was retracted

[[:db/retractEntity <msg-id>]]

the server would again notify the subscriber, this time indicating the retraction:

[[[<msg-id> "Hello!"] -1]]

This guarantees, that subscribers maintaining any form of functionally derived information will always have a consistent view of the data.

Query Language Features

  • Implicit joins and unions, and / or operators
  • Stratified negation
  • Parameterized queries
  • Rules, self-referential / mutually recursive rules
  • Aggregation (min, max, count, etc...)
  • Grouping via :with
  • Basic predicates (<=, <, >, >=, =, not=)
  • As-of queries
  • More find specifications (e.g. collection, scalar)
  • Pull queries
  • Queries across many heterogeneous data sources

Please also have a look at the open issues to get a sense for what we're working on.

Non-Features

3DF is neither concerned with durability nor with consistency in the ACID sense. It is intended to be used in combination with a consistent, durable source-of-truth such as Datomic or Kafka.

Consequently, 3DF will accept whatever tuples it is supplied with. For example, whereas in Datomic two subsequent transactions on an empty database

(d/transact conn [[:db/add 123 :user/balance 1000]])
...
(d/transact conn [[:db/add 123 :user/balance 1500]])

would result in the following sets of datoms being added into the database:

[[123 :user/balance 1000 <tx1> true]]
...
[[123 :user/balance 1000 <tx2> false]
 [123 :user/balance 1500 <tx2> true]]

3DF will by itself not take any previous information into account on transactions. Again, 3DF is intended to be fed data from a system like Datomic, which would ensure that transactions produce consistent tuples.

License

Copyright © 2018 Nikolas Göbel

Licensed under Eclipse Public License (see LICENSE).

clj-3df's People

Contributors

comnik avatar li1 avatar spacegangster avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.