Skip to content

Commit

Permalink
feat: check in max level for every friend id (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
friendlymatthew authored Jul 8, 2024
1 parent ff64eec commit ada059d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/hnsw/friends.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
type Point []float32

type Friends struct {
friends []*DistHeap
friends []*DistHeap
maxLevels map[Id]int
}

// NewFriends creates a new vector, note the max level is inclusive.
Expand All @@ -20,7 +21,8 @@ func NewFriends(topLevel int) *Friends {
}

return &Friends{
friends: friends,
friends: friends,
maxLevels: make(map[Id]int),
}
}

Expand Down Expand Up @@ -49,6 +51,8 @@ func (v *Friends) InsertFriendsAtLevel(level int, friendId Id, dist float32) {
for i := 0; i <= level; i++ {
v.friends[i].Insert(friendId, dist)
}

v.maxLevels[friendId] = level
}

func (v *Friends) GetFriendsAtLevel(level int) (*DistHeap, error) {
Expand Down

0 comments on commit ada059d

Please sign in to comment.