Skip to content
Open
18 changes: 14 additions & 4 deletions autotune.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package faiss
*/
import "C"
import (
"fmt"
"unsafe"
)

Expand All @@ -30,11 +31,20 @@ func (p *ParameterSpace) SetIndexParameter(idx Index, name string, val float64)
C.free(unsafe.Pointer(cname))
}()

c := C.faiss_ParameterSpace_set_index_parameter(
p.ps, idx.cPtr(), cname, C.double(val))
if c != 0 {
return getLastError()
switch idx.(type) {
case FloatIndex:
idx := idx.(*IndexImpl)
c := C.faiss_ParameterSpace_set_index_parameter(
p.ps, idx.cPtrFloat(), cname, C.double(val))
if c != 0 {
return getLastError()
}
case BinaryIndex:
return fmt.Errorf("binary indexes not supported for auto-tuning")
default:
return fmt.Errorf("unsupported index type")
}

return nil
}

Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module github.com/blevesearch/go-faiss

go 1.21
go 1.22

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was changed in a recent patch so update.

toolchain go1.23.0
Loading