Skip to content

Commit

Permalink
resolved review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shivaji-kharse committed May 9, 2024
1 parent 94ec396 commit df73eb9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions tok/hnsw/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (
DotProd = "dotproduct"
plError = "\nerror fetching posting list for data key: "
dataError = "\nerror fetching data for data key: "
EmptyHNSWTreeError = "HNSW tree has no elements"
VecKeyword = "__vector_"
visitedVectorsLevel = "visited_vectors_level_"
distanceComputations = "vector_distance_computations"
Expand Down
4 changes: 2 additions & 2 deletions tok/hnsw/persistent_hnsw.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,10 @@ func (ph *persistentHNSW[T]) calculateNewEntryVec(
})

if err != nil {
return 0, errors.Wrapf(err, "HNSW tree has no elements")
return 0, errors.Wrapf(err, EmptyHNSWTreeError)
}
if itr == 0 {
return itr, errors.New("HNSW tree has no elements")
return itr, errors.New(EmptyHNSWTreeError)
}

return itr, nil
Expand Down
2 changes: 1 addition & 1 deletion worker/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func (qs *queryState) handleValuePostings(ctx context.Context, args funcArgs) er
int(numNeighbors), index.AcceptAll[float32])
}

if err != nil && !strings.Contains(err.Error(), "HNSW tree has no elements: Key not found") {
if err != nil && !strings.Contains(err.Error(), hnsw.EmptyHNSWTreeError+": "+badger.ErrKeyNotFound.Error()) {
return err
}
sort.Slice(nnUids, func(i, j int) bool { return nnUids[i] < nnUids[j] })
Expand Down

0 comments on commit df73eb9

Please sign in to comment.