Skip to content

Commit 4f40c35

Browse files
committed
fix(benchmark): connect start slots to real graph sources
1 parent b30f486 commit 4f40c35

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

‎diskann-benchmark/src/index/build.rs‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
use std::{num::NonZeroUsize, sync::Arc};
77

8+
#[cfg(feature = "pipnn")]
9+
use diskann::graph::AdjacencyList;
810
use diskann::{
911
error::DiskANNError::StartPointComputeError,
1012
graph::{DiskANNIndex, StartPointStrategy},
@@ -170,10 +172,18 @@ where
170172
.context("PiPNN cannot connect a start point to an empty dataset")
171173
})
172174
.collect::<anyhow::Result<Vec<_>>>()?;
173-
let start_neighbors: Vec<_> = start_sources
175+
let degree = graph.pruned_degree().get();
176+
let start_neighbors = start_sources
174177
.into_iter()
175-
.map(|source| adjacency[source].clone())
176-
.collect();
178+
.map(|source| {
179+
let source_id = u32::try_from(source).context("PiPNN start source exceeds u32::MAX")?;
180+
let mut neighbors = AdjacencyList::with_capacity(degree);
181+
neighbors.push(source_id);
182+
neighbors.extend_from_slice(&adjacency[source]);
183+
neighbors.truncate(degree);
184+
Ok(neighbors)
185+
})
186+
.collect::<anyhow::Result<Vec<_>>>()?;
177187
let batch_elapsed = started.elapsed();
178188

179189
// Unlike incremental insertion, PiPNN finishes all batch-build scratch
@@ -461,5 +471,15 @@ mod pipnn_tests {
461471
.get_vector_sync(starts[0] as usize)
462472
};
463473
assert_eq!(start, [0.0, 0.0]);
474+
let mut neighbors = AdjacencyList::new();
475+
index
476+
.provider()
477+
.neighbors()
478+
.get_neighbors_sync(starts[0] as usize, &mut neighbors)
479+
.unwrap();
480+
assert!(
481+
neighbors.contains(0),
482+
"start slot must enter the real graph"
483+
);
464484
}
465485
}

0 commit comments

Comments
 (0)