Skip to content

Commit

Permalink
Revert " Propagate context to Search operation. (#2117)"
Browse files Browse the repository at this point in the history
This reverts commit 0bdc7ae.
  • Loading branch information
ykadowak committed Nov 30, 2023
1 parent 2cffb7b commit 98f7751
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 169 deletions.
11 changes: 2 additions & 9 deletions internal/core/algorithm/ngt/ngt.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ package ngt
import "C"

import (
"context"
"reflect"
"sync"
"unsafe"
Expand All @@ -41,7 +40,7 @@ type (
// NGT is core interface.
NGT interface {
// Search returns search result as []SearchResult
Search(ctx context.Context, vec []float32, size int, epsilon, radius float32) ([]SearchResult, error)
Search(vec []float32, size int, epsilon, radius float32) ([]SearchResult, error)

// Linear Search returns linear search result as []SearchResult
LinearSearch(vec []float32, size int) ([]SearchResult, error)
Expand Down Expand Up @@ -367,7 +366,7 @@ func (n *ngt) loadObjectSpace() error {
}

// Search returns search result as []SearchResult.
func (n *ngt) Search(ctx context.Context, vec []float32, size int, epsilon, radius float32) (result []SearchResult, err error) {
func (n *ngt) Search(vec []float32, size int, epsilon, radius float32) (result []SearchResult, err error) {
if len(vec) != int(n.dimension) {
return nil, errors.ErrIncompatibleDimensionSize(len(vec), int(n.dimension))
}
Expand Down Expand Up @@ -416,12 +415,6 @@ func (n *ngt) Search(ctx context.Context, vec []float32, size int, epsilon, radi
result = make([]SearchResult, rsize)

for i := range result {
select {
case <-ctx.Done():
n.PutErrorBuffer(ebuf)
return result[:i], nil
default:
}
d := C.ngt_get_result(results, C.uint32_t(i), ebuf)
if d.id == 0 && d.distance == 0 {
result[i] = SearchResult{0, 0, n.newGoError(ebuf)}
Expand Down
Loading

0 comments on commit 98f7751

Please sign in to comment.