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

Fix hack/benchmark search interface change #2129

Merged
merged 2 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
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
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