Skip to content

Commit

Permalink
Fix hack/benchmark search interface change (#2129)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevindiu authored and ykadowak committed Jul 25, 2023
1 parent 13143ab commit 1b918b5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions hack/benchmark/core/benchmark/strategy/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewSearch(size int, epsilon, radius float32, opts ...StrategyOption) benchm
}
b.StartTimer()
defer b.StopTimer()
return c.Search(v.([]float32), size, epsilon, radius)
return c.Search(ctx, v.([]float32), size, epsilon, radius)
},
),
WithPreProp64(
Expand All @@ -59,7 +59,7 @@ func NewSearch(size int, epsilon, radius float32, opts ...StrategyOption) benchm
}
b.StartTimer()
defer b.StopTimer()
return c.Search(float32To64(v.([]float32)), size, epsilon, radius)
return c.Search(ctx, float32To64(v.([]float32)), size, epsilon, radius)
},
),
}, opts...)...)
Expand Down
6 changes: 4 additions & 2 deletions hack/benchmark/internal/core/algorithm/algorithm.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
// Package algorithm provides core interface
package algorithm

import "context"

type Mode uint32

const (
Expand All @@ -29,7 +31,7 @@ type Closer interface {
}

type Bit32 interface {
Search(vec []float32, size int, epsilon, radius float32) (interface{}, error)
Search(ctx context.Context, vec []float32, size int, epsilon, radius float32) (interface{}, error)
Insert(vec []float32) (uint, error)
InsertCommit(vec []float32, poolSize uint32) (uint, error)
BulkInsert(vecs [][]float32) ([]uint, []error)
Expand All @@ -44,7 +46,7 @@ type Bit32 interface {
}

type Bit64 interface {
Search(vec []float64, size int, epsilon, radius float32) (interface{}, error)
Search(ctx context.Context, vec []float64, size int, epsilon, radius float32) (interface{}, error)
Insert(vec []float64) (uint, error)
InsertCommit(vec []float64, poolSize uint32) (uint, error)
BulkInsert(vecs [][]float64) ([]uint, []error)
Expand Down
5 changes: 3 additions & 2 deletions hack/benchmark/internal/core/algorithm/ngt/ngt.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package ngt

import (
"context"
"os"

c "github.com/vdaas/vald/hack/benchmark/internal/core/algorithm"
Expand Down Expand Up @@ -74,8 +75,8 @@ func New(opts ...Option) (c.Bit32, error) {
return c, nil
}

func (c *core) Search(vec []float32, size int, epsilon, radius float32) (interface{}, error) {
return c.NGT.Search(vec, size, epsilon, radius)
func (c *core) Search(ctx context.Context, vec []float32, size int, epsilon, radius float32) (interface{}, error) {
return c.NGT.Search(ctx, vec, size, epsilon, radius)
}

func (c *core) Close() {
Expand Down

0 comments on commit 1b918b5

Please sign in to comment.