Skip to content

Conversation

@Arshdeep54
Copy link
Contributor

HNSW implementation referenced from HNSW (Malkov & Yashunin)

Includes the following public functions :

  • Insert
  • Search
  • Delete (Soft Delete)
  • Rebuild

@Arshdeep54 Arshdeep54 self-assigned this Oct 5, 2025
@Arshdeep54 Arshdeep54 force-pushed the hnsw-index branch 5 times, most recently from e160cf5 to 3a275c3 Compare December 21, 2025 09:12
Arshdeep54 added a commit to Arshdeep54/indexium that referenced this pull request Dec 21, 2025
HNSW implementation code from my PR on sdslabs/VortexDB
sdslabs/VortexDB#43

Signed-off-by: Arshdeep54 <balarsh535@gmail.com>
@Arshdeep54 Arshdeep54 force-pushed the hnsw-index branch 2 times, most recently from 1d98363 to f883ad4 Compare December 25, 2025 16:27
Signed-off-by: Arshdeep54 <balarsh535@gmail.com>
// Per-node, per-level neighbor lists (bounded by M/M0)
pub nodes: HashMap<PointId, Node>,
// Number of points inserted
pub nb_point: usize,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nb_point is never utilized or updated

// Cached dimension of stored vectors
pub data_dimension: Dimension,
// Guard against concurrent mutation during queries
pub searching: bool,
Copy link
Collaborator

Choose a reason for hiding this comment

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

this flag is never utilized?

let mut current = ep;
loop {
let cur_vec = self.get_vec(current);
let mut best_score = distance(query.to_vec(), cur_vec.to_vec(), self.similarity);
Copy link
Collaborator

Choose a reason for hiding this comment

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

need to change distance function to take references instead of copies, otherwise it will be slower. I changed distance function accordingly in KD Tree PR, please check that.

/// - greedy descend from current entry to l+1 to get a pivot
/// - for each level down to 0: ef-construction, diversity pruning, bidirectional connect with caps
/// - if l is above current max level, update the entry point
fn insert(&mut self, vector: IndexedVector) -> Result<(), DbError> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

add a check that a point with same id does not exist already.

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.

3 participants