Expand description
Property index support for efficient lookups.
This module provides property indexes that transform O(n) property scans into O(log n) or O(1) lookups, dramatically improving query performance on large graphs.
§Index Types
| Type | Use Case | Lookup Complexity |
|---|---|---|
BTreeIndex | Range queries, ordered iteration | O(log n) + O(k) |
UniqueIndex | Exact match with uniqueness constraint | O(1) average |
§Example
ⓘ
use interstellar::index::IndexBuilder;
use interstellar::storage::Graph;
let graph = Graph::new();
// Create a B+ tree index for range queries
graph.create_index(
IndexBuilder::vertex()
.label("person")
.property("age")
.build()
.unwrap()
).unwrap();
// Create a unique index for O(1) lookups with uniqueness constraint
graph.create_index(
IndexBuilder::vertex()
.label("user")
.property("email")
.unique()
.build()
.unwrap()
).unwrap();
// Queries automatically use indexes when applicable
let adults = graph.gremlin().v()
.has_label("person")
.has_where("age", p::gte(18))
.to_list();§How It Works
-
Index Creation: When you create an index, existing data is scanned and indexed. The index is then maintained automatically on insert/update/delete.
-
Automatic Selection: Filter steps like
has_value()andhas_where()check for applicable indexes and use them when beneficial. -
Transparent Integration: Both the Gremlin-style traversal API and GQL queries benefit from indexes without any API changes.
Structs§
- BTree
Index - B+ tree index for range queries.
- Index
Builder - Fluent builder for index creation.
- Index
Filter - A filter that can potentially use an index.
- Index
Spec - Specification for creating an index.
- Index
Statistics - Statistics for query optimization.
- Unique
Index - Hash-based unique index with O(1) lookup.
Enums§
- Element
Type - Element type for indexing.
- Index
Error - Errors that can occur during index operations.
- Index
Predicate - Predicates that can use indexes.
- Index
Type - Type of index structure.
Traits§
- Property
Index - Trait for property index implementations.