Expand description
§Graph_D: A Native Graph Database Implementation
Graph_D is a memory-efficient, embedded graph database written in Rust with built-in JSON support. It provides SQLite-like simplicity with native graph operations and O(1) traversal performance.
§Key Features
- Native Graph Storage: Index-free adjacency for O(1) traversal performance
- JSON Properties: First-class JSON support for flexible node and relationship properties
- Memory Efficiency: Designed for embedded applications with minimal memory footprint
- Thread Safety: ACID-compliant operations with concurrent read support
- Query Language: GQL (Graph Query Language) with SQL-like syntax
- Secondary Indexing: Fast property-based lookups and range queries
- Persistence: Memory-mapped file storage for durability
§Quick Start
use graph_d::{Graph, Result};
use serde_json::json;
use std::collections::HashMap;
// Create a new in-memory graph
let mut graph = Graph::new()?;
// Create nodes with JSON properties
let mut alice_props = HashMap::new();
alice_props.insert("name".to_string(), json!("Alice"));
alice_props.insert("age".to_string(), json!(30));
let alice_id = graph.create_node(alice_props)?;
let mut bob_props = HashMap::new();
bob_props.insert("name".to_string(), json!("Bob"));
bob_props.insert("age".to_string(), json!(25));
let bob_id = graph.create_node(bob_props)?;
// Create a relationship between nodes
let mut rel_props = HashMap::new();
rel_props.insert("since".to_string(), json!("2020-01-01"));
let _rel_id = graph.create_relationship(
alice_id,
bob_id,
"KNOWS".to_string(),
rel_props
)?;
// Query nodes by ID
if let Some(alice) = graph.get_node(alice_id)? {
assert_eq!(alice.properties.get("name"), Some(&json!("Alice")));
}
// Find relationships by type
let knows_rels = graph.find_relationships_by_type("KNOWS")?;
assert_eq!(knows_rels.len(), 1);§Persistence
use graph_d::{Graph, Result};
use std::path::Path;
// Create or open a persistent graph database
let mut graph = Graph::open(Path::new("my_graph.db"))?;
// All operations are automatically persisted
// Data will be recovered when reopening the file§Module Organization
graph- Core graph data structures and operationsstorage- Storage backends (in-memory and persistent)index- Secondary indexing system for fast queriesgql- Graph Query Language implementationquery- Query building and execution utilitiestransaction- Transaction management and concurrency controlmemory- Advanced memory management and optimizationerror- Error types and result handling
Re-exports§
pub use error::GraphError;pub use error::Result;pub use graph::Graph;pub use graph::Node;pub use graph::Relationship;
Modules§
- error
- Error types and result handling for the graph database.
- gql
- GQL (Graph Query Language) implementation for Graph_D.
- graph
- Core graph data structures and operations.
- index
- Comprehensive indexing system for fast property and relationship lookups.
- memory
- Advanced memory management for the graph database.
- query
- Query engine for graph traversal and filtering.
- storage
- Storage layer for the graph database.
- transaction
- Transaction management for ACID compliance.
Constants§
- VERSION
- Version information for the graph database.