mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-23 04:27:11 +00:00
Major new package implementing a distributed hypergraph database with: ## Core Components (crates/ruvector-graph/) - Cypher-compatible query parser with lexer, AST, optimizer - Query execution engine with SIMD optimization and parallel execution - ACID transaction support with MVCC isolation levels - Distributed consensus and federation layer - Vector-graph hybrid queries for AI/RAG workloads - Performance optimizations (100x faster than Neo4j target) ## Bindings - WASM bindings (crates/ruvector-graph-wasm/) - NAPI-RS Node.js bindings (crates/ruvector-graph-node/) - NPM packages for both targets ## CLI Integration - 8 new graph commands: create, query, shell, import, export, info, benchmark, serve ## CI/CD - Updated build-native.yml for graph packages - New graph-ci.yml for testing and benchmarks - New graph-release.yml for automated publishing ## Data Generation - OpenRouter/Kimi K2 integration (packages/graph-data-generator/) - Agentic-synth benchmark suite integration ## Tests & Benchmarks - 11 test files covering all components - Criterion benchmarks for performance validation - Neo4j compatibility test suite ## Architecture Highlights - CSR graph layout for cache-friendly access - SIMD-vectorized query operators - Roaring bitmaps for label indexes - Bloom filters for fast negative lookups - Adaptive radix tree for property indexes Note: This is a comprehensive implementation created by 15 parallel agents. Some integration fixes may be needed to resolve cross-module dependencies. Co-authored-by: Claude AI Swarm <swarm@claude.ai>
122 lines
4.1 KiB
Rust
122 lines
4.1 KiB
Rust
//! Cypher Query Examples
|
|
//!
|
|
//! This example demonstrates Neo4j-compatible Cypher queries:
|
|
//! - CREATE: Creating nodes and relationships
|
|
//! - MATCH: Pattern matching
|
|
//! - WHERE: Filtering results
|
|
//! - RETURN: Projecting results
|
|
//! - Aggregations and complex queries
|
|
|
|
fn main() {
|
|
println!("=== RuVector Graph - Cypher Queries ===\n");
|
|
|
|
// TODO: Once the graph API is exposed, implement:
|
|
|
|
println!("1. Simple CREATE Query");
|
|
// let query = "CREATE (n:Person {name: 'Charlie', age: 28}) RETURN n";
|
|
// let result = db.execute_cypher(query)?;
|
|
// println!(" Query: {}", query);
|
|
// println!(" Result: {:?}", result);
|
|
|
|
println!("\n2. Pattern Matching");
|
|
// let query = r#"
|
|
// MATCH (p:Person)
|
|
// WHERE p.age > 25
|
|
// RETURN p.name, p.age
|
|
// ORDER BY p.age DESC
|
|
// "#;
|
|
// let result = db.execute_cypher(query)?;
|
|
// println!(" Query: {}", query);
|
|
// println!(" Result: {:?}", result);
|
|
|
|
println!("\n3. Creating Relationships");
|
|
// let query = r#"
|
|
// MATCH (a:Person {name: 'Alice'})
|
|
// MATCH (b:Person {name: 'Charlie'})
|
|
// CREATE (a)-[r:KNOWS {since: 2023}]->(b)
|
|
// RETURN r
|
|
// "#;
|
|
// let result = db.execute_cypher(query)?;
|
|
// println!(" Query: {}", query);
|
|
// println!(" Result: {:?}", result);
|
|
|
|
println!("\n4. Traversal Queries");
|
|
// let query = r#"
|
|
// MATCH (start:Person {name: 'Alice'})-[:KNOWS*1..3]->(end:Person)
|
|
// RETURN end.name, length((start)-[:KNOWS*]->(end)) as distance
|
|
// ORDER BY distance
|
|
// "#;
|
|
// let result = db.execute_cypher(query)?;
|
|
// println!(" Query: {}", query);
|
|
// println!(" Result: {:?}", result);
|
|
|
|
println!("\n5. Aggregation Queries");
|
|
// let query = r#"
|
|
// MATCH (p:Person)
|
|
// RETURN
|
|
// count(p) as total_people,
|
|
// avg(p.age) as average_age,
|
|
// min(p.age) as youngest,
|
|
// max(p.age) as oldest
|
|
// "#;
|
|
// let result = db.execute_cypher(query)?;
|
|
// println!(" Query: {}", query);
|
|
// println!(" Result: {:?}", result);
|
|
|
|
println!("\n6. Shortest Path");
|
|
// let query = r#"
|
|
// MATCH path = shortestPath(
|
|
// (a:Person {name: 'Alice'})-[:KNOWS*]-(b:Person {name: 'Bob'})
|
|
// )
|
|
// RETURN path, length(path) as distance
|
|
// "#;
|
|
// let result = db.execute_cypher(query)?;
|
|
// println!(" Query: {}", query);
|
|
// println!(" Result: {:?}", result);
|
|
|
|
println!("\n7. Pattern Comprehension");
|
|
// let query = r#"
|
|
// MATCH (p:Person)
|
|
// RETURN p.name, [(p)-[:KNOWS]->(friend) | friend.name] as friends
|
|
// "#;
|
|
// let result = db.execute_cypher(query)?;
|
|
// println!(" Query: {}", query);
|
|
// println!(" Result: {:?}", result);
|
|
|
|
println!("\n8. Complex Multi-Pattern Query");
|
|
// let query = r#"
|
|
// MATCH (p:Person)-[:LIVES_IN]->(city:City)
|
|
// MATCH (p)-[:WORKS_AT]->(company:Company)
|
|
// WHERE city.name = 'San Francisco' AND company.industry = 'Tech'
|
|
// RETURN p.name, company.name, p.salary
|
|
// ORDER BY p.salary DESC
|
|
// LIMIT 10
|
|
// "#;
|
|
// let result = db.execute_cypher(query)?;
|
|
// println!(" Query: {}", query);
|
|
// println!(" Result: {:?}", result);
|
|
|
|
println!("\n9. Updating Properties with Cypher");
|
|
// let query = r#"
|
|
// MATCH (p:Person {name: 'Alice'})
|
|
// SET p.age = p.age + 1, p.updated_at = timestamp()
|
|
// RETURN p
|
|
// "#;
|
|
// let result = db.execute_cypher(query)?;
|
|
// println!(" Query: {}", query);
|
|
// println!(" Result: {:?}", result);
|
|
|
|
println!("\n10. Conditional Creation (MERGE)");
|
|
// let query = r#"
|
|
// MERGE (p:Person {email: 'alice@example.com'})
|
|
// ON CREATE SET p.name = 'Alice', p.created_at = timestamp()
|
|
// ON MATCH SET p.last_seen = timestamp()
|
|
// RETURN p
|
|
// "#;
|
|
// let result = db.execute_cypher(query)?;
|
|
// println!(" Query: {}", query);
|
|
// println!(" Result: {:?}", result);
|
|
|
|
println!("\n=== Example Complete ===");
|
|
println!("\nNote: This is a template. Actual implementation pending graph API exposure.");
|
|
}
|