https://github.com/dyedgreen/cqlite
Embedded graph database
https://github.com/dyedgreen/cqlite
cypher-query-language graph graph-database rust
Last synced: 15 days ago
JSON representation
Embedded graph database
- Host: GitHub
- URL: https://github.com/dyedgreen/cqlite
- Owner: dyedgreen
- License: mit
- Created: 2021-09-01T21:37:15.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-06-12T20:51:46.000Z (almost 2 years ago)
- Last Synced: 2025-04-13T04:13:19.122Z (15 days ago)
- Topics: cypher-query-language, graph, graph-database, rust
- Language: Rust
- Homepage: https://crates.io/crates/cqlite
- Size: 178 KB
- Stars: 115
- Watchers: 5
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CQLite
[](https://crates.io/crates/cqlite)
[](https://docs.rs/cqlite)
[](https://github.com/dyedgreen/cqlite/actions/workflows/ci.yml)
[](./LICENSE)An embedded graph database implemented in Rust. This is currently a pre-release. It has not been
extensively tested with 'real-world work-loads', and the file-format and API are not yet stabilized.The longer term goal is to create an in-process graph database with a stable on-disk format and
support for a wide range of programming languages, providing a native Rust API, as well as a C FFI interface.```rust
use cqlite::Graph;let graph = Graph::open_anon()?;
let mut txn = graph.mut_txn()?;
let edge: u64 = graph.prepare(
"
CREATE (a:PERSON { name: 'Peter Parker' })
CREATE (b:PERSON { name: 'Clark Kent' })
CREATE (a) -[e:KNOWS]-> (b)
RETURN ID(e)
"
)?
.query_map(&mut txn, (), |m| m.get(0))?
.next()
.unwrap()?;
txn.commit()?;let name: String = graph.prepare(
"
MATCH (p:PERSON) <-[e:KNOWS]- (:PERSON)
WHERE ID(e) = $edge
RETURN p.name
"
)?
.query_map(&mut graph.txn()?, ("edge", edge), |m| m.get(0))?
.next()
.unwrap()?;
assert_eq!("Clark Kent", name);
```## Architecture Overview
### Parser :: `src/parser`
PEG grammar and parser for a subset of the `CYPHER` graph query language
### Query Planner :: `src/planner`
Transforms a parsed query ast into a logical query plan. Performs some
optimizations on the query plan.### Byte-Code Interpreter :: `src/runtime`
Defines a simple 'byte' code (`Instructions`) and can execute those against a given
database, as well as generate instructions for a given query plan.### Storage Backend :: `src/store`
Uses a disc-backed `btree` to provide basic storage, iteration and lockup for nodes and
edges.