Skip to main content

Module engine

Module engine 

Source
Expand description

A Cypher engine that registers its datasets once and serves many queries.

CypherEngine holds a snapshot of every input: the DataFusion context, the catalog, join-key statistics and, with use_csr, the CSR adjacencies and node indexes. Queries share the snapshot read-only; CypherEngine::refresh builds a complete replacement and swaps it in.

use std::collections::HashMap;
use lance_csr::engine::{CypherEngine, EngineSource};
use lance_csr::GraphConfig;

let config = GraphConfig::builder()
    .node_table("Person", "id")
    .rel_table("KNOWS", "Person", "Person", "src_id", "dst_id")
    .build()?;
let sources = HashMap::from([
    ("Person".to_string(), EngineSource::open_lance("data/person.lance", None, HashMap::new()).await?),
    ("KNOWS".to_string(), EngineSource::open_lance("data/knows.lance", None, HashMap::new()).await?),
]);
let engine = CypherEngine::new(config, sources, true).await?;
let batch = engine
    .execute("MATCH (a:Person)-[:KNOWS]->(b) RETURN a.name, b.name", HashMap::new())
    .await?;

Structs§

CsrStats
CSR adjacency statistics for one relationship type; see CypherEngine::csr_stats.
CypherEngine
Cypher query engine with a cached catalog for efficient multi-query execution.
NodeIndexStats
Node id -> row index statistics for one node label; see CypherEngine::node_index_stats.

Enums§

EngineSource
One input dataset as registered with a CypherEngine.

Constants§

MAX_TARGET_PARTITIONS
Upper bound for target_partitions: far above any core count, below values whose per-partition setup would exhaust memory instead of returning an error.