Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions diskann-providers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ bf-tree = { workspace = true, optional = true }
anyhow.workspace = true
prost = "0.14.1"
futures-util.workspace = true
futures-executor = "0.3"
Comment on lines 41 to +43
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New dependency is added with an inline version (futures-executor = "0.3") instead of using [workspace.dependencies] like most shared third-party crates in this repo. Consider adding it to the workspace dependency list and referencing it via workspace = true to keep versions consistent across crates.

Copilot uses AI. Check for mistakes.
polonius-the-crab = { version = "0.5.0", optional = true }
serde_json = { workspace = true, optional = true }
vfs = { workspace = true, optional = true }
Expand Down
58 changes: 57 additions & 1 deletion diskann-providers/src/index/wrapped_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
* Licensed under the MIT license.
*/

use futures_executor::block_on;
use std::{num::NonZeroUsize, sync::Arc};

use diskann::{
ANNResult,
ANNError, ANNResult,
graph::{
self, ConsolidateKind, InplaceDeleteMethod, SearchParams,
glue::{
Expand All @@ -20,6 +21,14 @@ use diskann::{
utils::{ONE, async_tools::VectorIdBoxSlice},
};

use crate::{
model::IndexConfiguration,
storage::{
AsyncIndexMetadata, AsyncQuantLoadContext, LoadWith, StorageReadProvider,
file_storage_provider::FileStorageProvider,
},
};

pub struct DiskANNIndex<DP: DataProvider> {
/// The underlying async DiskANNIndex.
pub inner: Arc<graph::DiskANNIndex<DP>>,
Expand Down Expand Up @@ -317,3 +326,50 @@ where
self.handle.block_on(self.inner.get_degree_stats(accessor))
}
}

pub trait SyncLoadWith<DP>: Sized {
fn load_with(path: &str, index_config: IndexConfiguration) -> ANNResult<Self>;
}

// Load static memory index from pre-built files synchronously
impl<DP> SyncLoadWith<DP> for DiskANNIndex<DP>
where
DP: DataProvider<InternalId = u32> + LoadWith<AsyncQuantLoadContext, Error = ANNError>,
{
fn load_with(path: &str, index_config: IndexConfiguration) -> ANNResult<DiskANNIndex<DP>> {
let storage = FileStorageProvider;
let data_provider = create_data_provider(&storage, path, &index_config);

match data_provider {
Ok(dp) => {
let index =
DiskANNIndex::<DP>::new_with_current_thread_runtime(index_config.config, dp);
Ok(index)
}
Err(e) => Err(e),
}
}
}

pub fn create_data_provider<'a, P, DP>(
provider: &P,
path: &'a str,
index_config: &'a IndexConfiguration,
) -> ANNResult<DP>
where
P: StorageReadProvider,
DP: DataProvider + LoadWith<AsyncQuantLoadContext, Error = ANNError>,
{
let pq_context = AsyncQuantLoadContext {
metadata: AsyncIndexMetadata::new(path),
num_frozen_points: index_config.num_frozen_pts,
metric: index_config.dist_metric,
prefetch_lookahead: index_config.prefetch_lookahead.map(|x| x.get()),
is_disk_index: false, // only support in-memory index loading here
prefetch_cache_line_level: index_config.prefetch_cache_line_level,
};
Comment on lines +363 to +370
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create_data_provider duplicates the existing storage::create_load_context() helper (diskann-providers/src/storage/index_storage.rs) that already builds an AsyncQuantLoadContext from IndexConfiguration. Reusing the shared helper would reduce drift and keep load semantics consistent across the crate.

Copilot uses AI. Check for mistakes.

let data_provider = DP::load_with(provider, &pq_context);

block_on(data_provider)
}
Comment on lines 372 to 375
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces futures_executor::block_on + a new futures-executor dependency just to synchronously wait for DP::load_with. Since this module already depends on Tokio and constructs runtimes/handles, prefer using a Tokio runtime/handle to block_on the load (or otherwise avoid adding an extra executor dependency).

Copilot uses AI. Check for mistakes.
Loading