Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
need this check because i accidentally used the API without giving a k value it panicked because in index.go in go-faiss you have func (idx *faissIndex) Search(x []float32, k int64) ( distances []float32, labels []int64, err error, ) { n := len(x) / idx.D() distances = make([]float32, int64(n)*k) labels = make([]int64, int64(n)*k) if c := C.faiss_Index_search( idx.idx, C.idx_t(n), (*C.float)(&x[0]), C.idx_t(k), (*C.float)(&distances[0]), (*C.idx_t)(&labels[0]), so if either k is 0 or query vector is nil/empty we get a panic because distances[0] is invalid operation
- Loading branch information