Files
opencloud/vendor/github.com/blevesearch/go-faiss/autotune.go
dependabot[bot] d31e179e86 chore(deps): bump github.com/blevesearch/bleve/v2 from 2.4.0 to 2.4.2
Bumps [github.com/blevesearch/bleve/v2](https://github.com/blevesearch/bleve) from 2.4.0 to 2.4.2.
- [Release notes](https://github.com/blevesearch/bleve/releases)
- [Commits](https://github.com/blevesearch/bleve/compare/v2.4.0...v2.4.2)

---
updated-dependencies:
- dependency-name: github.com/blevesearch/bleve/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-06 11:32:27 +02:00

45 lines
906 B
Go

package faiss
/*
#include <stdlib.h>
#include <faiss/c_api/AutoTune_c.h>
*/
import "C"
import (
"unsafe"
)
type ParameterSpace struct {
ps *C.FaissParameterSpace
}
// NewParameterSpace creates a new ParameterSpace.
func NewParameterSpace() (*ParameterSpace, error) {
var ps *C.FaissParameterSpace
if c := C.faiss_ParameterSpace_new(&ps); c != 0 {
return nil, getLastError()
}
return &ParameterSpace{ps}, nil
}
// SetIndexParameter sets one of the parameters.
func (p *ParameterSpace) SetIndexParameter(idx Index, name string, val float64) error {
cname := C.CString(name)
defer func() {
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()
}
return nil
}
// Delete frees the memory associated with p.
func (p *ParameterSpace) Delete() {
C.faiss_ParameterSpace_free(p.ps)
}