Skip to main content

Crate drevo_core

Crate drevo_core 

Source
Expand description

An embeddable property-graph engine: nodes and edges with JSON properties, held in memory, with optional write-ahead-log durability, ACID transactions, and secondary indexes that follow the graph through a change feed.

This is the engine underneath drevo, which adds Cypher, the HTTP and Bolt servers, and the Python bindings on top. Use drevo-core on its own when you want the graph inside your process and nothing else.

§Example

use drevo_core::engine::GraphEngine;
use drevo_core::model::{Direction, NewEdge, NewNode, Properties};
use drevo_core::native::NativeGraph;
use drevo_core::native_fts::NativeFtsIndex;

fn task(title: &str) -> NewNode {
    NewNode {
        kind: "task".into(),
        title: title.into(),
        body: String::new(),
        body_html: String::new(),
        properties: Properties::default(),
    }
}

let graph = NativeGraph::new(); // or NativeGraph::open_durable("graph.wal")?
let deploy = graph.create_node(task("Deploy release"))?;
let review = graph.create_node(task("Review release notes"))?;
graph.create_edge(NewEdge {
    from_id: deploy.id,
    to_id: review.id,
    kind: "blocked_by".into(),
    weight: 1.0,
    properties: Properties::default(),
})?;

let blockers = graph.neighbors(deploy.id, Direction::Outgoing, Some("blocked_by"))?;
assert_eq!(blockers[0].title, "Review release notes");

// Indexes catch up with the graph by reading its change feed.
let mut fts = NativeFtsIndex::new();
fts.sync(&graph);
assert_eq!(fts.search("deploy", 1)[0].0, deploy.id);

§Where to start

Modules§

bm25
Okapi BM25 scoring primitives.
csr
Compressed-Sparse-Row adjacency snapshot for cache-friendly, lock-free parallel scans and graph algorithms.
delta
Version-vector delta exchange for multi-writer convergence.
dump
The drevo-json-v1 dump format: a whole graph as one value.
engine
GraphEngine — the graph operations, as a trait.
error
The error type of drevo-core.
hlc
Hybrid Logical Clock (HLC) — causal versioning primitive for multi-writer convergence.
labels
The _labels secondary-label convention.
lww
Last-Writer-Wins register, map and set CRDTs for multi-writer convergence.
model
Data model types for drevo.
native
NativeGraph — the graph engine.
native_fts
In-memory BM25 full-text search over a NativeGraph, kept current from its change feed.
native_label_index
An in-memory secondary-label index over a NativeGraph, kept current from its change feed.
native_property_index
An in-memory property-value index over a NativeGraph, kept current from its change feed.
replica
WAL-shipping read replica of a NativeGraph, for read scaling and failover.
tokenizer
Text tokenization for full-text search: normalization plus character trigram and word extraction, with CJK-aware handling.
value_encoding
Canonical byte encoding of property values for index keyspaces.