Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: check in max level for every friend id #369

Merged
merged 2 commits into from
Jul 8, 2024
Merged
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
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
friendlymatthew marked this conversation as resolved.
Show resolved Hide resolved
}

// 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
Loading