Skip to content

Commit ba9b4d3

Browse files
committed
README update
1 parent 5a0a17d commit ba9b4d3

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,35 @@
1-
# datalog-rs
2-
Lightweight Datalog engine in Rust
1+
# datafrog
2+
3+
Datafrog is a lightweight Datalog engine intended to be embedded in other Rust programs.
4+
5+
Datafrog has no runtime, and relies on you to build and repeatedly apply the update rules.
6+
It tries to help you do this correctly. As an example, here is how you might write a reachability
7+
query using Datafrog (minus the part where we populate the `nodes` and `edges` initial relations).
8+
9+
```rust
10+
extern crate datafrog;
11+
use datafrog::Iteration;
12+
13+
fn main() {
14+
15+
// Create a new iteration context, ...
16+
let mut iteration = Iteration::new();
17+
18+
// .. some variables, ..
19+
let nodes_var = iteration.variable::<(u32,u32)>("nodes");
20+
let edges_var = iteration.variable::<(u32,u32)>("edges");
21+
22+
// .. load them with some initial values, ..
23+
nodes_var.insert(nodes.into());
24+
edges_var.insert(edges.into());
25+
26+
// .. and then start iterating rules!
27+
while iteration.changed() {
28+
// nodes(a,c) <- nodes(a,b), edges(b,c)
29+
nodes_var.from_join(&nodes_var, &edges_var, |_b, &a, &c| (c,a));
30+
}
31+
32+
// extract a `Vec<(u32,u32)>` containing the final results.
33+
let reachable = variable.complete();
34+
}
35+
```

0 commit comments

Comments
 (0)