Skip to main content

SeleneGraph

Struct SeleneGraph 

Source
pub struct SeleneGraph {
Show 14 fields pub meta: GraphMeta, pub node_store: NodeStore, pub edge_store: EdgeStore, pub adjacency_out: GenericHashMap<NodeId, AdjacencyEntry, FxBuildHasher, DefaultSharedPtr>, pub adjacency_in: GenericHashMap<NodeId, AdjacencyEntry, FxBuildHasher, DefaultSharedPtr>, pub idx_label: HashMap<DbString, RoaringBitmap>, pub idx_edge_label: HashMap<DbString, RoaringBitmap>, pub property_index: FxHashMap<(DbString, DbString), PropertyIndexEntry>, pub edge_property_index: FxHashMap<(DbString, DbString), PropertyIndexEntry>, pub composite_property_index: FxHashMap<(DbString, SmallVec<[DbString; 4]>), CompositePropertyIndexEntry>, pub vector_index: FxHashMap<(DbString, DbString), VectorIndexEntry>, pub text_index: FxHashMap<(DbString, DbString), TextIndexEntry>, pub node_id_to_row: GenericHashMap<NodeId, RowIndex, FxBuildHasher, DefaultSharedPtr>, pub edge_id_to_row: GenericHashMap<EdgeId, RowIndex, FxBuildHasher, DefaultSharedPtr>,
}
Expand description

Immutable graph snapshot.

Fields§

§meta: GraphMeta

Snapshot metadata.

§node_store: NodeStore

Node storage.

§edge_store: EdgeStore

Edge storage.

§adjacency_out: GenericHashMap<NodeId, AdjacencyEntry, FxBuildHasher, DefaultSharedPtr>

Outgoing adjacency keyed by source node.

§adjacency_in: GenericHashMap<NodeId, AdjacencyEntry, FxBuildHasher, DefaultSharedPtr>

Incoming adjacency keyed by target node.

§idx_label: HashMap<DbString, RoaringBitmap>

Bitmap of node rows carrying each label.

§idx_edge_label: HashMap<DbString, RoaringBitmap>

Bitmap of edge rows carrying each edge label.

§property_index: FxHashMap<(DbString, DbString), PropertyIndexEntry>

Per-(label, property) node value indexes. See spec 03 section 5.2.

§edge_property_index: FxHashMap<(DbString, DbString), PropertyIndexEntry>

Per-(edge label, property) edge value indexes.

§composite_property_index: FxHashMap<(DbString, SmallVec<[DbString; 4]>), CompositePropertyIndexEntry>

Per-(label, properties...) node composite value indexes.

§vector_index: FxHashMap<(DbString, DbString), VectorIndexEntry>

Per-(label, property) node vector indexes.

§text_index: FxHashMap<(DbString, DbString), TextIndexEntry>

Per-(label, property) node BM25 text indexes.

§node_id_to_row: GenericHashMap<NodeId, RowIndex, FxBuildHasher, DefaultSharedPtr>

External NodeId -> RowIndex lookup (the inverse of NodeStore::row_to_id). Replaces the id.get() - 1 arithmetic so the external id can stay stable while the row is remapped by compaction (D22 / BRIEF-Item-4a). imbl for cheap copy-on-write snapshot clones.

§edge_id_to_row: GenericHashMap<EdgeId, RowIndex, FxBuildHasher, DefaultSharedPtr>

External EdgeId -> RowIndex lookup (inverse of EdgeStore::row_to_id).

Implementations§

Source§

impl SeleneGraph

Source

pub fn assert_indexes_consistent(&self) -> Result<(), String>

Re-derive every built-in index from the authoritative node/edge columns and assert it matches the maintained index state.

Returns Ok(()) when the snapshot is internally consistent, or Err(message) describing the first detected drift. Intended for debug assertions and tests — it allocates fresh reference indexes and is O(nodes * indexes + edges) per call.

§Checked invariant families
  1. Label / edge-label bitmaps match a re-derivation from alive node label sets and alive edge labels; no bucket is present-but-empty.
  2. Typed property indexes match a fresh lenient re-build (build_property_index_lenient). The lenient policy is reused so open-graph kind drift and NaN — which the commit path legitimately skips — do not false-positive.
  3. Composite typed indexes match a fresh lenient re-build, same skip-aware policy.
  4. Vector row-set indexes match a fresh lenient re-build, same skip-aware policy.
  5. Text BM25 indexes match a fresh re-build from string properties.
  6. Store integrity / alive-set parity: per-store columns share one length and every alive row index is in range. Dead rows are permitted holes (D11) and are only asserted absent from derived state, never from the columns. The snapshot’s meta.next_*_id allocator high-water marks are intentionally not checked here: the published snapshot’s meta is allowed to carry stale allocator fields after a from_graph / recovery load (the real allocator floor is enforced separately by IdAllocator::from_meta_with_floors), so they are not a derived-index invariant.
  7. Adjacency matches a re-derivation from alive edges in both directions, with no present-but-empty entry.
§Errors

Returns the first mismatch as a human-readable String.

Source§

impl SeleneGraph

Source

pub fn new(graph_id: GraphId) -> Self

Construct an empty graph snapshot.

Source

pub const fn graph_id(&self) -> GraphId

Return this graph snapshot’s stable graph ID.

Source

pub fn node_count(&self) -> usize

Number of alive nodes.

Source

pub fn live_nodes(&self) -> &RoaringBitmap

Bitmap of alive node row indices.

Returned bitmap is row-indexed (matching nodes_with_label), not NodeId-indexed; consumers convert a row to its external NodeId via Self::node_id_for_row (never by row + 1 arithmetic — the external id is stable while compaction renumbers the row). Used by selene-algorithms to seed the “all alive nodes” baseline of a GraphProjection.

Source

pub fn edge_count(&self) -> usize

Number of alive edges.

Source

pub fn compaction_stats(&self) -> CompactionStats

Return current row-space pressure for compaction planning.

This is a cheap read over store lengths and liveness bitmaps; it does not rebuild indexes or allocate a dense graph.

Source

pub fn live_edges(&self) -> &RoaringBitmap

Bitmap of alive edge row indices.

The edge-side sibling of Self::live_nodes. The returned bitmap is row-indexed (matching edges_with_label), not EdgeId-indexed; consumers convert a row to its external EdgeId via Self::edge_id_for_row (never by row + 1 arithmetic). Covers every alive edge regardless of label — used by the DROP GRAPH factory-reset (BRIEF-152) to enumerate every live edge, including untyped/arbitrary-label ones that a per-type truncate would miss.

Source

pub fn row_for_node_id(&self, id: NodeId) -> Option<RowIndex>

Map an external NodeId to its internal RowIndex.

Returns None for a never-committed (aborted-tx hole) id. A deleted id still resolves — to its now-dead row — so liveness, not existence, distinguishes it (the row’s alive bit is clear). This is the map-backed replacement for the old id - 1 arithmetic; the external id stays stable while BRIEF-Item-4b compaction renumbers the row.

Source

pub fn row_for_edge_id(&self, id: EdgeId) -> Option<RowIndex>

Map an external EdgeId to its internal RowIndex; see Self::row_for_node_id.

Source

pub fn node_id_for_row(&self, row: RowIndex) -> Option<NodeId>

Recover the external NodeId bound to a materialized RowIndex.

Reads the row_to_id column (the persistence-stable per-row id), never synthesizing row + 1. Returns None past the column end or for a never-committed hole row (which holds NodeId::TOMBSTONE).

Source

pub fn edge_id_for_row(&self, row: RowIndex) -> Option<EdgeId>

Recover the external EdgeId bound to a materialized RowIndex; see Self::node_id_for_row.

Source

pub fn is_node_alive(&self, id: NodeId) -> bool

Return true when id names an alive node.

Source

pub fn is_edge_alive(&self, id: EdgeId) -> bool

Return true when id names an alive edge.

Source

pub fn node_labels(&self, id: NodeId) -> Option<&LabelSet>

Return node labels for an alive node.

Source

pub fn node_properties(&self, id: NodeId) -> Option<&PropertyMap>

Return node properties for an alive node.

Source

pub fn edge_label(&self, id: EdgeId) -> Option<&DbString>

Return edge label for an alive edge.

Source

pub fn edge_endpoints(&self, id: EdgeId) -> Option<(NodeId, NodeId)>

Return edge endpoints for an alive edge.

Source

pub fn edge_properties(&self, id: EdgeId) -> Option<&PropertyMap>

Return edge properties for an alive edge.

Source

pub fn outgoing_edges(&self, source: NodeId) -> Option<&AdjacencyEntry>

Return outgoing adjacency for source.

Source

pub fn incoming_edges(&self, target: NodeId) -> Option<&AdjacencyEntry>

Return incoming adjacency for target.

Source

pub fn node_has_incident_edges(&self, id: NodeId) -> bool

Return true when an alive node has at least one incident edge.

Source

pub fn nodes_with_label(&self, label: &DbString) -> Option<&RoaringBitmap>

Return the bitmap of node rows carrying label.

Source

pub fn edges_with_label(&self, label: &DbString) -> Option<&RoaringBitmap>

Return the bitmap of edge rows carrying label.

Source

pub fn label_count(&self) -> usize

Number of distinct node labels currently indexed.

Source

pub fn edge_label_count(&self) -> usize

Number of distinct edge labels currently indexed.

Source

pub fn property_index_for( &self, label: &DbString, property: &DbString, ) -> Option<Arc<TypedIndex>>

Return a clone of the registered (label, property) index.

Source

pub fn edge_property_index_for( &self, label: &DbString, property: &DbString, ) -> Option<Arc<TypedIndex>>

Return a clone of the registered edge (label, property) index.

Source

pub fn composite_property_index_for( &self, label: &DbString, properties: &[DbString], ) -> Option<Arc<CompositeTypedIndex>>

Return a clone of the registered composite index.

Source

pub fn composite_property_index_entry_for( &self, label: &DbString, properties: &[DbString], ) -> Option<&CompositePropertyIndexEntry>

Return composite index metadata for a property set.

Source

pub fn vector_index_for( &self, label: &DbString, property: &DbString, ) -> Option<Arc<VectorIndex>>

Return a clone of the registered vector index.

Source

pub fn text_index_for( &self, label: &DbString, property: &DbString, ) -> Option<Arc<TextIndex>>

Return a clone of the registered text index.

Source

pub fn property_index_count(&self) -> usize

Number of distinct (label, property) indexes currently registered.

Source

pub fn edge_property_index_count(&self) -> usize

Number of registered edge property indexes.

Source

pub fn composite_property_index_count(&self) -> usize

Number of distinct (label, properties...) indexes currently registered.

Source

pub fn vector_index_count(&self) -> usize

Number of distinct (label, property) vector indexes currently registered.

Source

pub fn text_index_count(&self) -> usize

Number of distinct (label, property) text indexes currently registered.

Source

pub fn iter_property_indexes( &self, ) -> impl Iterator<Item = (DbString, DbString, TypedIndexKind)> + '_

Iterate built-in property indexes as owned (label, property, kind) tuples.

This covers only SeleneGraph’s built-in property indexes. Extension-provider index state is surfaced through that provider’s own procedures.

Source

pub fn iter_property_index_entries( &self, ) -> impl Iterator<Item = (DbString, DbString, TypedIndexKind, Option<DbString>)> + '_

Iterate built-in property indexes with optional explicit catalog names.

Source

pub fn iter_composite_property_index_entries( &self, ) -> impl Iterator<Item = CompositePropertyIndexEntryRow> + '_

Iterate built-in composite property indexes with optional explicit catalog names.

Source

pub fn iter_vector_index_entries( &self, ) -> impl Iterator<Item = VectorIndexEntryRow> + '_

Iterate built-in vector indexes with optional explicit catalog names.

Source

pub fn iter_text_index_entries( &self, ) -> impl Iterator<Item = TextIndexEntryRow> + '_

Iterate built-in text indexes with optional explicit catalog names.

Source

pub fn nodes_with_property_eq( &self, label: &DbString, property: &DbString, value: &Value, ) -> Option<Cow<'_, RoaringBitmap>>

Return rows matching value under a registered property index.

None means no index is registered for (label, property) or the supplied value cannot be used with that index kind. Some(empty) means the index exists but no row matches. A kind-mismatched probe returns None so the caller drops to a linear scan; open-graph kind drift remains discoverable via cross-variant value_compare.

Source

pub fn nodes_with_property_any( &self, label: &DbString, property: &DbString, values: &[Value], ) -> Option<RoaringBitmap>

Return the union of node rows matching any indexed scalar value.

None means no node property index is registered for (label, property) or at least one supplied value cannot be used with that index kind. Some(empty) means the index exists but no row matches the value set.

Source

pub fn edges_with_property_eq( &self, label: &DbString, property: &DbString, value: &Value, ) -> Option<Cow<'_, RoaringBitmap>>

Return edge rows matching value under a registered edge property index.

None means no edge index is registered for (label, property) or the supplied value cannot be used with that index kind. Some(empty) means the index exists but no edge row matches.

Source

pub fn edges_with_property_any( &self, label: &DbString, property: &DbString, values: &[Value], ) -> Option<RoaringBitmap>

Return the union of edge rows matching any indexed scalar value.

None means no edge property index is registered for (label, property) or at least one supplied value cannot be used with that index kind. Some(empty) means the index exists but no row matches the value set.

Source

pub fn nodes_with_property_range<R>( &self, label: &DbString, property: &DbString, range: R, ) -> Option<RoaringBitmap>
where R: RangeBounds<Value>,

Return rows matching range under a registered property index.

None means no index is registered or the supplied bounds do not match the index kind. Some(empty) means the index exists but the range matches no rows.

Source

pub fn edges_with_property_range<R>( &self, label: &DbString, property: &DbString, range: R, ) -> Option<RoaringBitmap>
where R: RangeBounds<Value>,

Return edge rows matching range under a registered edge property index.

None means no edge index is registered or the supplied bounds do not match the index kind. Some(empty) means the index exists but no edge row matches.

Source

pub fn nodes_with_property_prefix( &self, label: &DbString, property: &DbString, prefix: &str, ) -> Option<RoaringBitmap>

Return rows whose string property key starts with prefix.

None means no index is registered or the registered index is not a string index.

Source§

impl SeleneGraph

Source

pub fn exact_json_contains_nodes( &self, label: &DbString, property: &DbString, candidate: &JsonValue, k: usize, ) -> GraphResult<Vec<JsonContainmentHit>>

Exhaustively find JSON-valued node properties containing candidate.

Source

pub fn exact_json_contains_nodes_checked( &self, label: &DbString, property: &DbString, candidate: &JsonValue, k: usize, checker: CancellationChecker<'_>, ) -> Result<Vec<JsonContainmentHit>, JsonSearchError>

Exhaustively find JSON-valued node properties with cancellation checks.

Source

pub fn exact_json_path_exists_nodes( &self, label: &DbString, property: &DbString, path: &[JsonPathSelector], k: usize, ) -> GraphResult<Vec<JsonPathHit>>

Exhaustively find JSON-valued node properties where path exists.

Source

pub fn exact_json_path_exists_nodes_checked( &self, label: &DbString, property: &DbString, path: &[JsonPathSelector], k: usize, checker: CancellationChecker<'_>, ) -> Result<Vec<JsonPathHit>, JsonSearchError>

Exhaustively find JSON-valued node properties with path-existence checks.

Source

pub fn exact_json_path_contains_nodes( &self, label: &DbString, property: &DbString, path: &[JsonPathSelector], candidate: &JsonValue, k: usize, ) -> GraphResult<Vec<JsonPathContainmentHit>>

Exhaustively find JSON-valued node properties whose selected path contains candidate.

Source

pub fn exact_json_path_contains_nodes_checked( &self, label: &DbString, property: &DbString, path: &[JsonPathSelector], candidate: &JsonValue, k: usize, checker: CancellationChecker<'_>, ) -> Result<Vec<JsonPathContainmentHit>, JsonSearchError>

Exhaustively find JSON path containment matches with cancellation checks.

Source

pub fn exact_json_path_value_nodes( &self, label: &DbString, property: &DbString, path: &[JsonPathSelector], k: usize, ) -> GraphResult<Vec<JsonPathValueHit>>

Exhaustively find JSON-valued node properties where path selects a value.

Source

pub fn exact_json_path_value_nodes_checked( &self, label: &DbString, property: &DbString, path: &[JsonPathSelector], k: usize, checker: CancellationChecker<'_>, ) -> Result<Vec<JsonPathValueHit>, JsonSearchError>

Exhaustively find JSON path values with cancellation checks.

Source§

impl SeleneGraph

Source

pub fn exact_json_contains_candidate_nodes( &self, label: &DbString, property: &DbString, candidate: &JsonValue, candidates: &[NodeId], k: usize, ) -> GraphResult<Vec<JsonContainmentHit>>

Find candidate nodes whose JSON property contains candidate.

Source

pub fn exact_json_contains_candidate_nodes_checked( &self, label: &DbString, property: &DbString, candidate: &JsonValue, candidates: &[NodeId], k: usize, checker: CancellationChecker<'_>, ) -> Result<Vec<JsonContainmentHit>, JsonSearchError>

Find candidate JSON containment matches with cancellation checks.

Source

pub fn exact_json_path_exists_candidate_nodes( &self, label: &DbString, property: &DbString, path: &[JsonPathSelector], candidates: &[NodeId], k: usize, ) -> GraphResult<Vec<JsonPathHit>>

Find candidate nodes whose JSON property has path.

Source

pub fn exact_json_path_exists_candidate_nodes_checked( &self, label: &DbString, property: &DbString, path: &[JsonPathSelector], candidates: &[NodeId], k: usize, checker: CancellationChecker<'_>, ) -> Result<Vec<JsonPathHit>, JsonSearchError>

Find candidate JSON path-existence matches with cancellation checks.

Source

pub fn exact_json_path_contains_candidate_nodes( &self, label: &DbString, property: &DbString, options: JsonPathContainmentCandidateOptions<'_>, ) -> GraphResult<Vec<JsonPathContainmentHit>>

Find candidate nodes whose selected JSON path contains candidate.

Source

pub fn exact_json_path_contains_candidate_nodes_checked( &self, label: &DbString, property: &DbString, options: JsonPathContainmentCandidateOptions<'_>, checker: CancellationChecker<'_>, ) -> Result<Vec<JsonPathContainmentHit>, JsonSearchError>

Find candidate JSON path-containment matches with cancellation checks.

Source

pub fn exact_json_path_value_candidate_nodes( &self, label: &DbString, property: &DbString, path: &[JsonPathSelector], candidates: &[NodeId], k: usize, ) -> GraphResult<Vec<JsonPathValueHit>>

Return selected JSON values for matching candidate nodes.

Source

pub fn exact_json_path_value_candidate_nodes_checked( &self, label: &DbString, property: &DbString, path: &[JsonPathSelector], candidates: &[NodeId], k: usize, checker: CancellationChecker<'_>, ) -> Result<Vec<JsonPathValueHit>, JsonSearchError>

Return selected candidate JSON path values with cancellation checks.

Source§

impl SeleneGraph

Source

pub fn build_text_index( &self, label: &DbString, property: &DbString, ) -> GraphResult<TextIndex>

Build a reusable BM25 postings index for label.property.

The returned index is tied to this graph snapshot. Mutations committed after the snapshot is read require rebuilding or durable registration in a later maintained-index layer.

§Errors

Returns GraphError::Inconsistent if graph label/property columns are internally inconsistent while the snapshot is scanned.

Source

pub fn indexed_text_search_nodes( &self, label: &DbString, property: &DbString, query: &str, k: usize, ) -> GraphResult<Vec<TextSearchHit>>

Rank string-valued node properties through a transient postings index.

This is primarily useful for tests and benchmark comparisons. Repeated production queries should build a TextIndex once and call TextIndex::search directly.

§Errors

Returns GraphError::Inconsistent if index construction observes corrupt graph columns.

Source§

impl SeleneGraph

Source

pub fn exact_text_search_nodes( &self, label: &DbString, property: &DbString, query: &str, k: usize, ) -> GraphResult<Vec<TextSearchHit>>

Exhaustively rank string-valued node properties using BM25.

This is the full-text correctness oracle and small-corpus path. It scans the row bitmap for label, skips nodes where property is absent or not a string, tokenizes documents with the built-in Unicode-aware tokenizer, and ranks matches with Okapi BM25 (k1 = 1.2, b = 0.75). Query tokens are deduplicated so repeated query terms do not overweight a document.

Source

pub fn exact_text_search_nodes_checked( &self, label: &DbString, property: &DbString, query: &str, k: usize, checker: CancellationChecker<'_>, ) -> Result<Vec<TextSearchHit>, TextSearchError>

Exhaustively rank string-valued node properties with cancellation checks.

Source

pub fn exact_text_search_nodes_in_rows_checked( &self, label: &DbString, property: &DbString, query: &str, k: usize, allowed_rows: &RoaringBitmap, checker: CancellationChecker<'_>, ) -> Result<Vec<TextSearchHit>, TextSearchError>

Exhaustively rank text documents while admitting only allowed_rows.

BM25 corpus statistics are still computed over every string document for (label, property), so scores and ordering match an unfiltered search whose full ranking is filtered by this row set before k truncation.

Source§

impl SeleneGraph

Source

pub fn approximate_vector_search_nodes_in_rows_checked( &self, label: &DbString, property: &DbString, query: &VectorValue, allowed_rows: &RoaringBitmap, options: ApproximateVectorSearchOptions, checker: CancellationChecker<'_>, ) -> Result<Vec<VectorNodeSearchHit>, VectorSearchError>

Approximately rank vector-valued node properties while admitting only rows in allowed_rows.

Source§

impl SeleneGraph

Source

pub fn approximate_vector_search_candidate_set_checked( &self, label: &DbString, property: &DbString, query: &VectorValue, candidates: &VectorCandidateSet, options: ApproximateVectorSearchOptions, checker: CancellationChecker<'_>, ) -> Result<Vec<VectorNodeSearchHit>, VectorSearchError>

Approximately rank a canonical node candidate set through a TurboQuant index.

This is the approximate counterpart to Self::score_vector_candidate_set_checked: callers supply the candidate set explicitly, TurboQuant preselects up to ef_search candidates within that set, and the graph layer exact-reranks the returned rows against primary VECTOR values. Missing nodes, nodes outside the registered (label, property) vector index, and nodes without a vector value are skipped under the normal snapshot visibility rules. When the search width covers every surviving indexed candidate row, the compressed preselection pass is skipped and those rows are exact-scored directly.

Source

pub fn approximate_vector_search_candidate_sets_batch_checked( &self, label: &DbString, property: &DbString, queries: &[VectorValue], candidate_sets: &[VectorCandidateSet], options: ApproximateVectorSearchOptions, checker: CancellationChecker<'_>, ) -> Result<Vec<Vec<VectorNodeSearchHit>>, VectorSearchError>

Approximately rank one canonical node candidate set per query.

Each queries[i] is searched only within candidate_sets[i] through a matching TurboQuant index, then exact-reranked against primary vector values. Output positions correspond to input query positions.

Source§

impl SeleneGraph

Source

pub fn exact_vector_search_nodes_batch_checked( &self, label: &DbString, property: &DbString, queries: &[VectorValue], metric: VectorMetric, k: usize, checker: CancellationChecker<'_>, ) -> Result<Vec<Vec<VectorNodeSearchHit>>, VectorSearchError>

Exhaustively rank vector-valued node properties for a batch of queries.

The output position corresponds to the input query position. This keeps the exact single-query semantics but resolves the row set once and scans candidates once, which is useful for agent-memory workloads that probe several embeddings over the same (label, property) surface.

Source§

impl SeleneGraph

Source

pub fn score_vector_nodes( &self, property: &DbString, query: &VectorValue, candidates: &[NodeId], metric: VectorMetric, k: usize, ) -> GraphResult<Vec<VectorNodeSearchHit>>

Score an explicit node candidate set against one query vector.

This is the graph-retrieval rerank primitive: callers can produce candidates from graph pattern matches, graph algorithms, or ANN indexes, then rank only those nodes by a vector-valued property. Candidate ids are deduplicated before scoring. Missing, deleted, and non-vector candidates are skipped to match normal live-snapshot visibility.

Source

pub fn score_vector_nodes_checked( &self, property: &DbString, query: &VectorValue, candidates: &[NodeId], metric: VectorMetric, k: usize, checker: CancellationChecker<'_>, ) -> Result<Vec<VectorNodeSearchHit>, VectorSearchError>

Score explicit node candidates with cancellation checks.

This preserves Self::score_vector_nodes ordering and visibility while checking checker before work begins and every 1024 unique candidates.

Source

pub fn score_vector_candidate_set( &self, property: &DbString, query: &VectorValue, candidates: &VectorCandidateSet, metric: VectorMetric, k: usize, ) -> GraphResult<Vec<VectorNodeSearchHit>>

Score one canonical node candidate set against one query vector.

This is the zero-renormalization companion to Self::score_vector_nodes. Callers that already hold a VectorCandidateSet can avoid the extra sort/dedup pass while keeping the same live-snapshot visibility, metric, and hit ordering semantics.

Source

pub fn score_vector_candidate_set_checked( &self, property: &DbString, query: &VectorValue, candidates: &VectorCandidateSet, metric: VectorMetric, k: usize, checker: CancellationChecker<'_>, ) -> Result<Vec<VectorNodeSearchHit>, VectorSearchError>

Score one canonical node candidate set with cancellation checks.

Source

pub fn score_vector_nodes_batch<C>( &self, property: &DbString, queries: &[VectorValue], candidate_sets: &[C], metric: VectorMetric, k: usize, ) -> GraphResult<Vec<Vec<VectorNodeSearchHit>>>
where C: AsRef<[NodeId]>,

Score one explicit candidate set for each query vector.

The result position corresponds to the input query position. Candidate sets are independent and follow Self::score_vector_nodes semantics: each set is deduplicated, non-live or non-vector nodes are skipped, and hits are ordered by distance then node id. The method rejects mismatched query/candidate-set counts and mixed query dimensions before scoring.

Source

pub fn score_vector_nodes_batch_checked<C>( &self, property: &DbString, queries: &[VectorValue], candidate_sets: &[C], metric: VectorMetric, k: usize, checker: CancellationChecker<'_>, ) -> Result<Vec<Vec<VectorNodeSearchHit>>, VectorSearchError>
where C: AsRef<[NodeId]>,

Score batched explicit node candidates with cancellation checks.

This preserves Self::score_vector_nodes_batch ordering and visibility while checking checker before batch validation and before each query’s candidate set is scored.

Source

pub fn score_vector_candidate_sets_batch( &self, property: &DbString, queries: &[VectorValue], candidate_sets: &[VectorCandidateSet], metric: VectorMetric, k: usize, ) -> GraphResult<Vec<Vec<VectorNodeSearchHit>>>

Score one canonical candidate set for each query vector.

This is the batch companion to Self::score_vector_candidate_set. It preserves the generic batch scoring contract while avoiding a second normalization pass for callers that already hold canonical candidate sets.

Source

pub fn score_vector_candidate_sets_batch_checked( &self, property: &DbString, queries: &[VectorValue], candidate_sets: &[VectorCandidateSet], metric: VectorMetric, k: usize, checker: CancellationChecker<'_>, ) -> Result<Vec<Vec<VectorNodeSearchHit>>, VectorSearchError>

Score batched canonical candidate sets with cancellation checks.

Source

pub fn score_vector_neighbors( &self, property: &DbString, query: &VectorValue, anchor: NodeId, options: VectorNeighborSearchOptions<'_>, ) -> GraphResult<Vec<VectorNodeSearchHit>>

Score vector-valued neighbors reached from one anchor through edge_label.

This is the one-hop graph candidate-set companion to Self::score_vector_nodes. It derives candidates from the snapshot’s directed adjacency, then applies the same dedupe, visibility, metric, and ordering rules as explicit candidate scoring.

Source

pub fn score_vector_neighbors_checked( &self, property: &DbString, query: &VectorValue, anchor: NodeId, options: VectorNeighborSearchOptions<'_>, checker: CancellationChecker<'_>, ) -> Result<Vec<VectorNodeSearchHit>, VectorSearchError>

Score vector-valued neighbors with cancellation checks.

Source

pub fn score_vector_neighbors_batch( &self, property: &DbString, queries: &[VectorValue], anchors: &[NodeId], options: VectorNeighborSearchOptions<'_>, ) -> GraphResult<Vec<Vec<VectorNodeSearchHit>>>

Score one anchor’s vector-valued neighbors for each query vector.

queries[i] is scored against neighbors derived from anchors[i]. Mismatched query/anchor counts and mixed query dimensions are rejected before scoring.

Source

pub fn score_vector_neighbors_batch_checked( &self, property: &DbString, queries: &[VectorValue], anchors: &[NodeId], options: VectorNeighborSearchOptions<'_>, checker: CancellationChecker<'_>, ) -> Result<Vec<Vec<VectorNodeSearchHit>>, VectorSearchError>

Score batched one-hop graph neighbors with cancellation checks.

Source

pub fn score_vector_expanded_candidate_sets_batch( &self, property: &DbString, queries: &[VectorValue], root_sets: &[VectorCandidateSet], options: VectorNeighborSearchOptions<'_>, ) -> GraphResult<Vec<Vec<VectorNodeSearchHit>>>

Expand one canonical root set per query through one graph hop, then score it.

queries[i] is scored against root_sets[i] plus nodes reached from those roots through options.edge_label in options.direction. This is the batch graph-retrieval primitive for ANN-then-graph-expansion and graph-query-then-vector-rerank workloads.

Source

pub fn score_vector_expanded_candidate_sets_batch_checked( &self, property: &DbString, queries: &[VectorValue], root_sets: &[VectorCandidateSet], options: VectorNeighborSearchOptions<'_>, checker: CancellationChecker<'_>, ) -> Result<Vec<Vec<VectorNodeSearchHit>>, VectorSearchError>

Expand and score batched canonical root sets with cancellation checks.

Source

pub fn expand_vector_candidate_sets_batch_checked( &self, root_sets: &[VectorCandidateSet], edge_label: &DbString, direction: VectorNeighborDirection, k: usize, checker: CancellationChecker<'_>, ) -> Result<Vec<VectorCandidateSet>, VectorSearchError>

Expand one canonical root set per query through one graph hop.

This is the reusable batch expansion primitive used by graph-expanded vector scorers. It preserves input order, reuses duplicate root-set expansion work within bounded batches, and checks cancellation while deriving candidates.

Source

pub fn vector_neighbor_candidates( &self, anchor: NodeId, edge_label: &DbString, direction: VectorNeighborDirection, ) -> VectorCandidateSet

Return canonical vector-score candidates reached from one graph anchor.

Candidates are filtered by edge label and direction, sorted by NodeId, and deduplicated. The returned set intentionally does not check vector property presence or node liveness; scoring APIs apply normal snapshot visibility when the set is consumed.

Source

pub fn expand_vector_candidate_set( &self, roots: &VectorCandidateSet, edge_label: &DbString, direction: VectorNeighborDirection, ) -> VectorCandidateSet

Expand canonical candidates through one labeled graph hop.

The returned set contains every root candidate plus neighbors reached from those roots through edge_label in direction. This is the production primitive behind graph-authored support/provenance expansion: callers can build a small root set from graph queries or ANN hits, expand through graph topology, then pass the canonical result to vector scoring.

Source

pub fn expand_vector_candidate_set_checked( &self, roots: &VectorCandidateSet, edge_label: &DbString, direction: VectorNeighborDirection, checker: CancellationChecker<'_>, ) -> Result<VectorCandidateSet, VectorSearchError>

Expand canonical candidates through one labeled graph hop with cancellation checks.

Source§

impl SeleneGraph

Source

pub fn exact_vector_search_nodes( &self, label: &DbString, property: &DbString, query: &VectorValue, metric: VectorMetric, k: usize, ) -> GraphResult<Vec<VectorNodeSearchHit>>

Exhaustively rank vector-valued node properties for one label.

This is the correctness oracle and small-corpus path for future ANN indexes: it scans the row bitmap for label, skips nodes where property is absent or not a vector, and returns the exact best k matches. Graph structural inconsistencies are reported as GraphError::Inconsistent; vector metric errors such as dimension mismatch propagate through GraphError::Core.

Source

pub fn exact_vector_search_nodes_checked( &self, label: &DbString, property: &DbString, query: &VectorValue, metric: VectorMetric, k: usize, checker: CancellationChecker<'_>, ) -> Result<Vec<VectorNodeSearchHit>, VectorSearchError>

Exhaustively rank vector-valued node properties with cancellation checks.

This preserves the exact ordering and filtering contract of Self::exact_vector_search_nodes while checking checker before the scan and every 1024 candidate rows thereafter. It is the preferred path for GQL procedure execution because a large exact scan should remain cooperatively cancellable until ANN indexes take over this surface.

Source

pub fn approximate_vector_search_nodes_checked( &self, label: &DbString, property: &DbString, query: &VectorValue, options: ApproximateVectorSearchOptions, checker: CancellationChecker<'_>, ) -> Result<Vec<VectorNodeSearchHit>, VectorSearchError>

Approximately rank vector-valued node properties through an ANN index.

This is intentionally separate from Self::exact_vector_search_nodes: it requires a registered ANN vector index whose dimension and metric match the query, then returns the approximate result set produced by that derived index. Distances are exact for the candidates the ANN index returns, but recall is governed by ef_search. TurboQuant skips compressed preselection when ef_search.max(k) already covers every indexed row, because that path would exact-rerank the full row set.

Source

pub fn approximate_vector_search_nodes_batch_checked( &self, label: &DbString, property: &DbString, queries: &[VectorValue], options: ApproximateVectorSearchOptions, checker: CancellationChecker<'_>, ) -> Result<Vec<Vec<VectorNodeSearchHit>>, VectorSearchError>

Run approximate ANN vector search for a batch of queries.

The result at each output position corresponds to the query at the same input position and follows the same ordering, visibility, and error contract as Self::approximate_vector_search_nodes_checked. The batch path resolves the ANN index once and reuses scratch buffers where the algorithm supports them, making it the preferred native API when a caller has several independent embedding lookups over the same (label, property) index.

Source

pub fn approximate_vector_search_expanded_candidates_checked( &self, label: &DbString, property: &DbString, query: &VectorValue, options: ApproximateVectorExpansionOptions<'_>, checker: CancellationChecker<'_>, ) -> Result<Vec<VectorNodeSearchHit>, VectorSearchError>

Use ANN hits as graph roots, expand them, then exact-rerank candidates.

This composes the HNSW/IVF root-finding path with graph topology: approximate search chooses up to options.root_k seed nodes from the registered ANN index, one-hop graph expansion adds related candidates, then the expanded set is exact-reranked by the same vector property and metric. The ANN path remains explicit, so missing or metric-mismatched indexes return the same errors as Self::approximate_vector_search_nodes_checked.

Source

pub fn approximate_vector_search_expanded_candidates_batch_checked( &self, label: &DbString, property: &DbString, queries: &[VectorValue], options: ApproximateVectorExpansionOptions<'_>, checker: CancellationChecker<'_>, ) -> Result<Vec<Vec<VectorNodeSearchHit>>, VectorSearchError>

Batch ANN-root graph expansion followed by exact candidate reranking.

The result at each output position corresponds to the query at the same input position. ANN roots are produced through one shared (label, property) index, converted to canonical root sets, expanded through options.edge_label, then scored by Self::score_vector_expanded_candidate_sets_batch_checked.

Trait Implementations§

Source§

impl Clone for SeleneGraph

Source§

fn clone(&self) -> SeleneGraph

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SeleneGraph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more