Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rust-lang/datafrog
A lightweight Datalog engine in Rust
https://github.com/rust-lang/datafrog
Last synced: about 21 hours ago
JSON representation
A lightweight Datalog engine in Rust
- Host: GitHub
- URL: https://github.com/rust-lang/datafrog
- Owner: rust-lang
- License: apache-2.0
- Created: 2018-05-16T13:37:32.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-01-20T20:23:52.000Z (almost 3 years ago)
- Last Synced: 2024-12-13T10:30:03.339Z (9 days ago)
- Language: Rust
- Size: 167 KB
- Stars: 801
- Watchers: 48
- Forks: 45
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# 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).```rust
extern crate datafrog;
use datafrog::Iteration;fn main() {
// Prepare initial values, ..
let nodes: Vec<(u32,u32)> = vec![
// ..
];
let edges: Vec<(u32,u32)> = vec![
// ..
];// 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)> = nodes_var.complete();
}
```If you'd like to read more about how it works, check out [this blog post](https://github.com/frankmcsherry/blog/blob/master/posts/2018-05-19.md).
## Authorship
Datafrog was initially developed by [Frank McSherry][fmc] and was
later transferred to the rust-lang-nursery organization. Thanks Frank![fmc]: https://github.com/frankmcsherry