Skip to main content

Module index

Module index 

Source
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

TypeUse CaseLookup Complexity
BTreeIndexRange queries, ordered iterationO(log n) + O(k)
UniqueIndexExact match with uniqueness constraintO(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

  1. Index Creation: When you create an index, existing data is scanned and indexed. The index is then maintained automatically on insert/update/delete.

  2. Automatic Selection: Filter steps like has_value() and has_where() check for applicable indexes and use them when beneficial.

  3. Transparent Integration: Both the Gremlin-style traversal API and GQL queries benefit from indexes without any API changes.

Structs§

BTreeIndex
B+ tree index for range queries.
IndexBuilder
Fluent builder for index creation.
IndexFilter
A filter that can potentially use an index.
IndexSpec
Specification for creating an index.
IndexStatistics
Statistics for query optimization.
UniqueIndex
Hash-based unique index with O(1) lookup.

Enums§

ElementType
Element type for indexing.
IndexError
Errors that can occur during index operations.
IndexPredicate
Predicates that can use indexes.
IndexType
Type of index structure.

Traits§

PropertyIndex
Trait for property index implementations.