2021-01-15 14:38:36 +08:00
|
|
|
package indexnode
|
2020-12-28 16:55:50 +08:00
|
|
|
|
2022-03-21 14:23:24 +08:00
|
|
|
import "math/rand"
|
2020-12-28 16:55:50 +08:00
|
|
|
|
|
|
|
const (
|
2022-03-21 14:23:24 +08:00
|
|
|
dim = 8
|
|
|
|
nb = 10000
|
|
|
|
nprobe = 8
|
2020-12-28 16:55:50 +08:00
|
|
|
)
|
|
|
|
|
2020-12-29 16:31:03 +08:00
|
|
|
func generateFloatVectors() []float32 {
|
|
|
|
vectors := make([]float32, 0)
|
|
|
|
for i := 0; i < nb; i++ {
|
2021-01-06 18:19:44 +08:00
|
|
|
for j := 0; j < dim; j++ {
|
|
|
|
vectors = append(vectors, rand.Float32())
|
|
|
|
}
|
2020-12-29 16:31:03 +08:00
|
|
|
}
|
|
|
|
return vectors
|
|
|
|
}
|
|
|
|
|
|
|
|
func generateBinaryVectors() []byte {
|
|
|
|
vectors := make([]byte, 0)
|
2021-01-06 18:19:44 +08:00
|
|
|
for i := 0; i < nb; i++ {
|
|
|
|
for j := 0; j < dim/8; j++ {
|
|
|
|
vectors = append(vectors, byte(rand.Intn(8)))
|
|
|
|
}
|
2020-12-29 16:31:03 +08:00
|
|
|
}
|
|
|
|
return vectors
|
|
|
|
}
|