You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This allows using the ? operator throughout execution methods.
Constructors
Constructor
UnifiedEngine
Use Case
new()
No
Simple single-engine queries
with_engines(...)
No
Custom engine configuration
with_shared_store(...)
Yes
Cross-engine unified queries
use query_router::QueryRouter;use tensor_store::TensorStore;let router = QueryRouter::new();let router = QueryRouter::with_engines(relational, graph, vector);let store = TensorStore::new();let router = QueryRouter::with_shared_store(store);
Execution Methods
Method
Parser
Async
Distributed
Cache
execute(command)
AST
No
Yes
Yes
execute_parsed(command)
AST
No
Yes
Yes
execute_parsed_async(command)
AST
Yes
No
Yes
execute_statement(stmt)
Pre-parsed
No
No
No
execute_statement_async(stmt)
Pre-parsed
Yes
No
No
execute() and execute_parsed() are functionally equivalent -- both parse via
neumann_parser::parse(), check for distributed execution, apply caching, and
dispatch to execute_statement(). There is no legacy regex-based parsing path.
Statement Routing Table
Statement Type
Engine
Handler Method
Operations
Select
Relational
exec_select
Table queries with WHERE, JOIN, GROUP BY, ORDER BY
Insert
Relational
exec_insert
Single/multi-row insert, INSERT...SELECT
Update
Relational
exec_update
Row updates with conditions
Delete
Relational
exec_delete
Row deletion with protection
CreateTable
Relational
exec_create_table
Table DDL
DropTable
Relational
inline
Table removal with protection
CreateIndex
Relational
inline
Index creation
DropIndex
Relational
inline
Index removal with protection
ShowTables
Relational
inline
List tables
Describe
Multiple
exec_describe
Schema/node/edge info
Node
Graph
exec_node
CREATE/GET/DELETE/LIST/UPDATE
Edge
Graph
exec_edge
CREATE/GET/DELETE/LIST/UPDATE
Neighbors
Graph
exec_neighbors
Neighbor traversal
Path
Graph
exec_path
Path finding
Embed
Vector
exec_embed
Embedding storage, batch, delete
Similar
Vector
exec_similar
k-NN search
ShowEmbeddings
Vector
inline
List embedding keys
CountEmbeddings
Vector
inline
Count embeddings
Find
Unified
exec_find
Cross-engine queries
Entity
Unified
exec_entity
Entity CRUD
Vault
Vault
exec_vault
Secret management
Cache
Cache
exec_cache
LLM response cache
Blob
BlobStore
exec_blob
Artifact operations
Blobs
BlobStore
exec_blobs
Artifact listing
Checkpoint
Checkpoint
exec_checkpoint
Create snapshot
Rollback
Checkpoint
exec_rollback
Restore snapshot
Checkpoints
Checkpoint
exec_checkpoints
List snapshots
Chain
TensorChain
exec_chain
Blockchain operations
Cluster
Orchestrator
exec_cluster
Cluster management
Empty
---
inline
No-op
Supported Query Types
Relational Operations
CREATETABLEusers (id INT, name VARCHAR(100), email VARCHAR(255))
DROPTABLE users
INSERT INTO users (id, name, email) VALUES (1, 'Alice', 'alice@example.com')
INSERT INTO users SELECT*FROM temp_users
UPDATE users SET name ='Bob'WHERE id =1DELETEFROM users WHERE id =1SELECT*FROM users WHERE id =1SELECT id, name FROM users ORDER BY name ASCLIMIT10 OFFSET 5SELECTCOUNT(*), AVG(age) FROM users WHERE active = true GROUP BY dept HAVINGCOUNT(*) >5SELECT*FROM users u INNER JOIN orders o ONu.id=o.user_idSELECT*FROM users u LEFT JOIN profiles p ONu.id=p.user_idSELECT*FROM a CROSS JOIN b
SELECT*FROM a NATURAL JOIN b
Aggregate Functions
Function
Description
Null Handling
COUNT(*)
Count all rows
Counts nulls
COUNT(col)
Count non-null values
Excludes nulls
SUM(col)
Sum numeric values
Skips nulls
AVG(col)
Average numeric values
Skips nulls, returns NULL if no values
MIN(col)
Minimum value
Skips nulls
MAX(col)
Maximum value
Skips nulls
Graph Operations
NODE CREATE person { name: 'Alice', age: 30 }
NODE GET 123
NODE DELETE123
NODE LIST person LIMIT100
NODE UPDATE123 { name: 'Alice Smith' }
EDGE CREATE 1->2 : friend
EDGE GET 456
EDGE DELETE456
EDGE LIST friend LIMIT50
NEIGHBORS 1 friend OUTGOING
NEIGHBORS 123PATH1->5 VIA friend
Vector Operations
EMBED STORE 'doc1' [0.1, 0.2, 0.3, 0.4]
EMBED DELETE'doc1'
EMBED BATCH [('key1', [0.1, 0.2]), ('key2', [0.3, 0.4])]
SIMILAR 'doc1'LIMIT5
SIMILAR 'doc1'LIMIT5 EUCLIDEAN
SIMILAR [0.1, 0.2, 0.3] LIMIT10 COSINE
EMBED STORE 'doc1' [0.1, 0.2] INTO my_collection
SHOW EMBEDDINGS LIMIT100
COUNT EMBEDDINGS
Distance Metrics
Metric
Description
Use Case
Formula
COSINE
Cosine similarity (default)
Semantic similarity
`1 - (a.b) / (
EUCLIDEAN
Euclidean distance (L2)
Spatial distance
sqrt(sum((a_i - b_i)^2))
DOT_PRODUCT
Dot product
Magnitude-aware similarity
sum(a_i * b_i)
Unified Entity Operations
ENTITY CREATE 'user:1' {name: 'Alice'} EMBEDDING [0.1, 0.2, 0.3]
ENTITY CONNECT 'user:1'->'doc:1' : authored
SIMILAR 'query:key' CONNECTED TO 'hub:entity'LIMIT10
Vault Operations
VAULT SET'secret''value'
VAULT GET 'secret'
VAULT DELETE'secret'
VAULT LIST
VAULT GRANT'user:bob''secret'
VAULT REVOKE'user:bob''secret'
VAULT ROTATE 'secret'
Cache Operations
CACHE INIT
CACHE STATS
CACHE CLEAR
CACHE EVICT 100
CACHE GET 'key'
CACHE PUT 'key''value'
CACHE SEMANTIC GET 'query' THRESHOLD 0.9
CACHE SEMANTIC PUT 'query''response' [0.1, 0.2, 0.3]
Chain Operations
CHAIN BEGIN
CHAIN COMMIT
CHAIN ROLLBACK100
CHAIN HISTORY 'key'
CHAIN HEIGHT
CHAIN TIP
CHAIN BLOCK 42
CHAIN VERIFY
CHAIN SHOW CODEBOOK GLOBAL
CHAIN SHOW CODEBOOK LOCAL 'domain'
CHAIN ANALYZE TRANSITIONS
Cross-Engine Methods
Method
Description
Complexity
build_vector_index()
Build HNSW index for O(log n) search
O(n log n)
connect_entities(from, to, type)
Add graph edge between entities
O(1)
find_neighbors_by_similarity(key, query, k)
Neighbors sorted by vector similarity
O(k * log n) with HNSW
find_similar_connected(query, connected_to, k)
Similar AND connected entities
O(k * log n) + O(neighbors)
create_unified_entity(key, fields, embedding)
Create entity with all modalities
O(1)
Distributed Query Types
Query Plans
Plan
When Used
Example
Shards Contacted
Local
Point lookups on local shard
GET user:1 (local key)
1
Remote
Point lookups on remote shard
GET user:2 (remote key)
1
ScatterGather
Full scans, aggregates, similarity
SELECT *, SIMILAR, COUNT
All
Merge Strategies
Strategy
Description
Use Case
Algorithm
Union
Combine all results
SELECT, NODE queries
Concatenate rows/nodes/edges
TopK(k)
Keep top K by score
SIMILAR queries
Sort by score desc, truncate
Aggregate(func)
SUM, COUNT, AVG, MAX, MIN
Aggregate queries
Combine partial aggregates
FirstNonEmpty
First result found
Point lookups
Short-circuit on first result
Concat
Concatenate in order
Ordered results
Same as Union
DistributedQueryConfig
pubstructDistributedQueryConfig{/// Maximum concurrent shard queries (default: 10)pubmax_concurrent:usize,/// Query timeout per shard in milliseconds (default: 5000)pubshard_timeout_ms:u64,/// Retry count for failed shards (default: 2)pubretry_count:usize,/// Whether to fail fast on first shard error (default: false)pubfail_fast:bool,}
Query Caching
Cacheable statements are automatically cached when a cache is configured: