Skip to content

Commit 1b8bed8

Browse files
committed
GraphLayersWithVectors
1 parent e92c893 commit 1b8bed8

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

lib/segment/src/index/hnsw_index/graph_layers.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,15 @@ pub trait GraphLayersBase {
197197
}
198198
}
199199

200+
pub trait GraphLayersWithVectors {
201+
/// # Panics
202+
///
203+
/// Panics when using a format that does not support vectors.
204+
fn for_each_link_with_vector<F>(&self, point_id: PointOffsetType, level: usize, f: F)
205+
where
206+
F: FnMut(PointOffsetType, &[u8]);
207+
}
208+
200209
impl GraphLayersBase for GraphLayers {
201210
fn get_visited_list_from_pool(&self) -> VisitedListHandle<'_> {
202211
self.visited_pool.get(self.links.num_points())
@@ -214,6 +223,17 @@ impl GraphLayersBase for GraphLayers {
214223
}
215224
}
216225

226+
impl GraphLayersWithVectors for GraphLayers {
227+
fn for_each_link_with_vector<F>(&self, point_id: PointOffsetType, level: usize, mut f: F)
228+
where
229+
F: FnMut(PointOffsetType, &[u8]),
230+
{
231+
self.links
232+
.links_with_vectors(point_id, level)
233+
.for_each(|(point_id, vector)| f(point_id, vector));
234+
}
235+
}
236+
217237
/// Object contains links between nodes for HNSW search
218238
///
219239
/// Assume all scores are similarities. Larger score = closer points

0 commit comments

Comments
 (0)