graphersal 0.1.1

In-memory graph traversal engine modelled on Apache TinkerPop Gremlin, with a Rhai DSL, optimizer and GraphSON/GraphML I/O
Documentation

graphersal

An in-memory graph database and traversal engine in Rust, queried with Gremlin, the query language of Apache TinkerPop.

Playground · Book · Step reference · Repository

The web playground: a recursive traversal over a directory tree, its results and the graph

[dependencies]
graphersal = { version = "0.1", features = ["script", "io", "display"] }
use std::sync::Arc;

use graphersal::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // The TinkerPop "modern" sample graph: 4 people, 2 pieces of software, 6 edges.
    let graph = GraphSource::tinkerpop_modern();

    // The Rust API: a read lock gives a traversal source, a terminal runs the traversal.
    let friends = graph
        .read()
        .traversal()
        .v(None)
        .has("name", "marko")
        .out("knows")
        .values("name")
        .to_list()?;
    println!("{friends:?}"); // ["josh", "vadas"]

    // The same query as Gremlin text (feature `script`), in snake_case or camelCase.
    let names = graphersal::script::eval_value(
        Arc::new(graph),
        r#"g.V().has("name", "marko").out("knows").values("name").toList()"#,
    )?;
    println!("{names}"); // ["josh", "vadas"]
    Ok(())
}

What is in it

  • A property graph in memory: vertices with a set of labels, edges, properties of logical types (int64, float64, string, uuid, arrays, objects), indexes and graph statistics.
  • The Gremlin steps as a Rust API and as text, the Gremlin DSL (on Rhai), with a rule-based optimizer, bulk traversers and profile() / execute() showing the optimized plan with timings, counts and memory per step.
  • Every traversal is atomic: it commits completely or is rolled back. Explicit transactions, dry runs and change capture with commit hooks for everything around it.
  • Schemas in a subset of JSON Schema 2020-12, enforced on write in open or closed mode, inferred from data, patched, validated and diffed.
  • Running queries you did not write: resource limits, timeouts, cancellation, a memory budget and permissions (an Authorizer, for example the ready-made AccessPolicy::read_only()).
  • Saved queries: named, parameterized queries stored in the graph.
  • Persistence: lossless snapshots, a write-ahead journal, and the Store (one directory or one file = one graph) with point-in-time views, fork, rollback, verified backups and repair; the format is a public specification.
  • Your own storage: the whole engine is generic over the GraphStorage trait (EXPERIMENTAL in 0.1.x), with the conformance suite graphersal-storage-tests.

Features

All off by default and strictly additive:

Feature What it adds
script the Gremlin DSL as text, with safe default limits
io GraphSON 3.0 and GraphML import and export
display results rendered as tables
serde serialization of change sets and schemas, the JSON visualizer
persist snapshots, the journal and the Store; persist-zstd and persist-zip add zstd chunks and ZIP backups
alloc-tracking exact per-step memory figures in profile() (the binary installs the allocator)

Learn more

Graphersal is compatible with, and inspired by, Apache TinkerPop Gremlin. It is an independent project: it is not part of Apache TinkerPop and is not endorsed by the Apache Software Foundation.

Licensed under the Apache License, Version 2.0 (see LICENSE-APACHE and NOTICE).