Skip to content
A lightweight Datalog engine in Rust
Branch: master
Clone or download
nikomatsakis Merge pull request #21 from lqd/stats
Add Variable statistics
Latest commit 34055ab Jan 11, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples drive-by: squash annoying warning Dec 5, 2018
src Add Variable statistics Jan 9, 2019
.gitignore
.travis.yml add .travis.yml to at least build and run (nonexistent) tests Dec 5, 2018
CODE_OF_CONDUCT.md add the dual license files May 24, 2018
Cargo.toml release v2.0.1 Jan 2, 2019
LICENSE-APACHE add the dual license files May 24, 2018
LICENSE-MIT
README.md update the README May 24, 2018
RELEASES.md release v2.0.1 Jan 2, 2019

README.md

datafrog

Datafrog is a lightweight Datalog engine intended to be embedded in other Rust programs.

Datafrog has no runtime, and relies on you to build and repeatedly apply the update rules. It tries to help you do this correctly. As an example, here is how you might write a reachability query using Datafrog (minus the part where we populate the nodes and edges initial relations).

extern crate datafrog;
use datafrog::Iteration;

fn main() {

    // Create a new iteration context, ...
    let mut iteration = Iteration::new();

    // .. some variables, ..
    let nodes_var = iteration.variable::<(u32,u32)>("nodes");
    let edges_var = iteration.variable::<(u32,u32)>("edges");

    // .. load them with some initial values, ..
    nodes_var.insert(nodes.into());
    edges_var.insert(edges.into());

    // .. and then start iterating rules!
    while iteration.changed() {
        // nodes(a,c)  <-  nodes(a,b), edges(b,c)
        nodes_var.from_join(&nodes_var, &edges_var, |_b, &a, &c| (c,a));
    }

    // extract the final results.
    let reachable: Vec<(u32,u32)> = variable.complete();
}

If you'd like to read more about how it works, check out this blog post.

Authorship

Datafrog was initially developed by Frank McSherry and was later transferred to the rust-lang-nursery organization. Thanks Frank!

You can’t perform that action at this time.