Skip to content

[diskann] Make InsertStrategy independent of SearchStrategy - #1393

Draft
Mark Hildebrand (hildebrandmw) wants to merge 4 commits into
mainfrom
mhildebr/insert-strategy
Draft

Mark Hildebrand (hildebrandmw) wants to merge 4 commits into
mainfrom
mhildebr/insert-strategy

Conversation

@hildebrandmw

@hildebrandmw Mark Hildebrand (hildebrandmw) commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

This is a breaking change modifying diskann::graph::glue::InsertStrategy. The old form is

pub trait InsertStrategy<'a, Provider, T>:
    SearchStrategy<'a, Provider, T, SearchAccessor: SearchAccessor> + 'static
where
    Provider: DataProvider,
{
    type PruneStrategy: PruneStrategy<Provider>;

    fn prune_strategy(&self) -> Self::PruneStrategy;

    fn insert_search_accessor(
        &'a self,
        provider: &'a Provider,
        context: &'a Provider::Context,
        vector: T,
    ) -> Result<Self::SearchAccessor, Self::SearchAccessorError> {
        self.search_accessor(provider, context, vector)
    }
}

This PR changes the trait to

pub trait InsertStrategy<'a, Provider, T>: Send + Sync + 'static
where
    Provider: DataProvider,
{
    type SearchAccessor: SearchAccessor<Id = Provider::InternalId>;

    type SearchAccessorError: StandardError;

    type PruneStrategy: PruneStrategy<Provider>;

    fn insert_search_accessor(
        &'a self,
        provider: &'a Provider,
        context: &'a Provider::Context,
        vector: T,
    ) -> Result<Self::SearchAccessor, Self::SearchAccessorError>;

    fn prune_strategy(&self) -> Self::PruneStrategy;
}

The SearchStrategy super-trait is removed and the SearchAccessor becomes an associated type.

Why

We need to support use-cases where data provided through the insert api needs to be decoupled from search. This allows data + metadata to be inserted. The current SearchStrategy super-trait makes this much harder than necessary as it requires duplicating SearchStrategy implementations.

With this change, it's much easier to decouple the insert element types from the search element types.

Migration Guide

Migration should be straight forward. All existing InsertStrategy implementations already require SearchStrategy, so upgrading simply involves explicitly redirecting the SearchAccessor, SearchAccessorError, and insert_search_accessor types/methods to their corresponding implementations.

@codecov-commenter

Codecov Comments Bot (codecov-commenter) commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.56%. Comparing base (cc473fc) to head (81afe44).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1393      +/-   ##
==========================================
- Coverage   92.65%   91.56%   -1.10%     
==========================================
  Files         527      527              
  Lines      103254   103318      +64     
==========================================
- Hits        95674    94603    -1071     
- Misses       7580     8715    +1135     
Flag Coverage Δ
miri 91.56% <100.00%> (-1.10%) ⬇️
unittests 91.31% <100.00%> (-1.30%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
diskann-bftree/src/provider.rs 92.82% <100.00%> (+0.05%) ⬆️
diskann-garnet/src/provider.rs 79.28% <ø> (+0.06%) ⬆️
diskann-inmem/src/provider.rs 95.64% <100.00%> (+0.11%) ⬆️
diskann-providers/src/index/diskann_async.rs 96.66% <100.00%> (+<0.01%) ⬆️
...odel/graph/provider/async_/inmem/full_precision.rs 82.47% <100.00%> (+0.57%) ⬆️
...s/src/model/graph/provider/async_/inmem/product.rs 91.57% <100.00%> (+0.50%) ⬆️
...rs/src/model/graph/provider/async_/inmem/scalar.rs 91.56% <100.00%> (+0.16%) ⬆️
...src/model/graph/provider/async_/inmem/spherical.rs 92.32% <100.00%> (+0.13%) ⬆️
diskann/src/graph/glue.rs 85.71% <ø> (-0.61%) ⬇️
diskann/src/graph/test/provider.rs 95.39% <100.00%> (ø)

... and 44 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants