github.com/milvus-io/milvus-sdk-go/v2@v2.4.1/entity/indexes_gen_test.go (about) 1 // Code generated by go generate; DO NOT EDIT 2 // This file is generated by go generate 3 4 package entity 5 6 import ( 7 "testing" 8 9 "github.com/stretchr/testify/assert" 10 ) 11 12 13 func TestIndexFlat(t *testing.T){ 14 15 16 mt := L2 17 18 19 t.Run("valid usage case", func(t *testing.T){ 20 21 22 idx0, err := NewIndexFlat(mt, 23 ) 24 assert.Nil(t, err) 25 assert.NotNil(t, idx0) 26 assert.Equal(t, "Flat", idx0.Name()) 27 assert.EqualValues(t, "FLAT", idx0.IndexType()) 28 assert.NotNil(t, idx0.Params()) 29 assert.False(t, idx0.SupportBinary()) 30 31 }) 32 33 t.Run("invalid usage case", func(t *testing.T){ 34 35 }) 36 } 37 38 func TestIndexBinFlat(t *testing.T){ 39 40 var nlist int 41 42 mt := HAMMING 43 44 45 t.Run("valid usage case", func(t *testing.T){ 46 47 nlist = 10 48 idx0, err := NewIndexBinFlat(mt, 49 nlist, 50 ) 51 assert.Nil(t, err) 52 assert.NotNil(t, idx0) 53 assert.Equal(t, "BinFlat", idx0.Name()) 54 assert.EqualValues(t, "BIN_FLAT", idx0.IndexType()) 55 assert.NotNil(t, idx0.Params()) 56 assert.True(t, idx0.SupportBinary()) 57 58 }) 59 60 t.Run("invalid usage case", func(t *testing.T){ 61 62 nlist = 0 63 idx0, err := NewIndexBinFlat(mt, 64 nlist, 65 ) 66 assert.NotNil(t, err) 67 assert.Nil(t, idx0) 68 69 nlist = 65537 70 idx1, err := NewIndexBinFlat(mt, 71 nlist, 72 ) 73 assert.NotNil(t, err) 74 assert.Nil(t, idx1) 75 76 }) 77 } 78 79 func TestIndexIvfFlat(t *testing.T){ 80 81 var nlist int 82 83 mt := L2 84 85 86 t.Run("valid usage case", func(t *testing.T){ 87 88 nlist = 10 89 idx0, err := NewIndexIvfFlat(mt, 90 nlist, 91 ) 92 assert.Nil(t, err) 93 assert.NotNil(t, idx0) 94 assert.Equal(t, "IvfFlat", idx0.Name()) 95 assert.EqualValues(t, "IVF_FLAT", idx0.IndexType()) 96 assert.NotNil(t, idx0.Params()) 97 assert.False(t, idx0.SupportBinary()) 98 99 }) 100 101 t.Run("invalid usage case", func(t *testing.T){ 102 103 nlist = 0 104 idx0, err := NewIndexIvfFlat(mt, 105 nlist, 106 ) 107 assert.NotNil(t, err) 108 assert.Nil(t, idx0) 109 110 nlist = 65537 111 idx1, err := NewIndexIvfFlat(mt, 112 nlist, 113 ) 114 assert.NotNil(t, err) 115 assert.Nil(t, idx1) 116 117 }) 118 } 119 120 func TestIndexBinIvfFlat(t *testing.T){ 121 122 var nlist int 123 124 mt := HAMMING 125 126 127 t.Run("valid usage case", func(t *testing.T){ 128 129 nlist = 10 130 idx0, err := NewIndexBinIvfFlat(mt, 131 nlist, 132 ) 133 assert.Nil(t, err) 134 assert.NotNil(t, idx0) 135 assert.Equal(t, "BinIvfFlat", idx0.Name()) 136 assert.EqualValues(t, "BIN_IVF_FLAT", idx0.IndexType()) 137 assert.NotNil(t, idx0.Params()) 138 assert.True(t, idx0.SupportBinary()) 139 140 }) 141 142 t.Run("invalid usage case", func(t *testing.T){ 143 144 nlist = 0 145 idx0, err := NewIndexBinIvfFlat(mt, 146 nlist, 147 ) 148 assert.NotNil(t, err) 149 assert.Nil(t, idx0) 150 151 nlist = 65537 152 idx1, err := NewIndexBinIvfFlat(mt, 153 nlist, 154 ) 155 assert.NotNil(t, err) 156 assert.Nil(t, idx1) 157 158 }) 159 } 160 161 func TestIndexIvfSQ8(t *testing.T){ 162 163 var nlist int 164 165 mt := L2 166 167 168 t.Run("valid usage case", func(t *testing.T){ 169 170 nlist = 10 171 idx0, err := NewIndexIvfSQ8(mt, 172 nlist, 173 ) 174 assert.Nil(t, err) 175 assert.NotNil(t, idx0) 176 assert.Equal(t, "IvfSQ8", idx0.Name()) 177 assert.EqualValues(t, "IVF_SQ8", idx0.IndexType()) 178 assert.NotNil(t, idx0.Params()) 179 assert.False(t, idx0.SupportBinary()) 180 181 }) 182 183 t.Run("invalid usage case", func(t *testing.T){ 184 185 nlist = 0 186 idx0, err := NewIndexIvfSQ8(mt, 187 nlist, 188 ) 189 assert.NotNil(t, err) 190 assert.Nil(t, idx0) 191 192 nlist = 65537 193 idx1, err := NewIndexIvfSQ8(mt, 194 nlist, 195 ) 196 assert.NotNil(t, err) 197 assert.Nil(t, idx1) 198 199 }) 200 } 201 202 func TestIndexIvfPQ(t *testing.T){ 203 204 var nlist int 205 var m int 206 var nbits int 207 208 mt := L2 209 210 211 t.Run("valid usage case", func(t *testing.T){ 212 213 nlist, m, nbits = 10, 8, 8 214 idx0, err := NewIndexIvfPQ(mt, 215 nlist, 216 m, 217 nbits, 218 ) 219 assert.Nil(t, err) 220 assert.NotNil(t, idx0) 221 assert.Equal(t, "IvfPQ", idx0.Name()) 222 assert.EqualValues(t, "IVF_PQ", idx0.IndexType()) 223 assert.NotNil(t, idx0.Params()) 224 assert.False(t, idx0.SupportBinary()) 225 226 }) 227 228 t.Run("invalid usage case", func(t *testing.T){ 229 230 nlist, m, nbits = 0, 8, 8 231 idx0, err := NewIndexIvfPQ(mt, 232 nlist, 233 m, 234 nbits, 235 ) 236 assert.NotNil(t, err) 237 assert.Nil(t, idx0) 238 239 nlist, m, nbits = 65537, 8, 8 240 idx1, err := NewIndexIvfPQ(mt, 241 nlist, 242 m, 243 nbits, 244 ) 245 assert.NotNil(t, err) 246 assert.Nil(t, idx1) 247 248 nlist, m, nbits = 10, 8, 0 249 idx2, err := NewIndexIvfPQ(mt, 250 nlist, 251 m, 252 nbits, 253 ) 254 assert.NotNil(t, err) 255 assert.Nil(t, idx2) 256 257 nlist, m, nbits = 10, 8, 17 258 idx3, err := NewIndexIvfPQ(mt, 259 nlist, 260 m, 261 nbits, 262 ) 263 assert.NotNil(t, err) 264 assert.Nil(t, idx3) 265 266 }) 267 } 268 269 func TestIndexHNSW(t *testing.T){ 270 271 var M int 272 var efConstruction int 273 274 mt := L2 275 276 277 t.Run("valid usage case", func(t *testing.T){ 278 279 M, efConstruction = 16, 40 280 idx0, err := NewIndexHNSW(mt, 281 M, 282 efConstruction, 283 ) 284 assert.Nil(t, err) 285 assert.NotNil(t, idx0) 286 assert.Equal(t, "HNSW", idx0.Name()) 287 assert.EqualValues(t, "HNSW", idx0.IndexType()) 288 assert.NotNil(t, idx0.Params()) 289 assert.False(t, idx0.SupportBinary()) 290 291 }) 292 293 t.Run("invalid usage case", func(t *testing.T){ 294 295 M, efConstruction = 3, 40 296 idx0, err := NewIndexHNSW(mt, 297 M, 298 efConstruction, 299 ) 300 assert.NotNil(t, err) 301 assert.Nil(t, idx0) 302 303 M, efConstruction = 65, 40 304 idx1, err := NewIndexHNSW(mt, 305 M, 306 efConstruction, 307 ) 308 assert.NotNil(t, err) 309 assert.Nil(t, idx1) 310 311 M, efConstruction = 16, 7 312 idx2, err := NewIndexHNSW(mt, 313 M, 314 efConstruction, 315 ) 316 assert.NotNil(t, err) 317 assert.Nil(t, idx2) 318 319 M, efConstruction = 16, 513 320 idx3, err := NewIndexHNSW(mt, 321 M, 322 efConstruction, 323 ) 324 assert.NotNil(t, err) 325 assert.Nil(t, idx3) 326 327 }) 328 } 329 330 func TestIndexIvfHNSW(t *testing.T){ 331 332 var nlist int 333 var M int 334 var efConstruction int 335 336 mt := L2 337 338 339 t.Run("valid usage case", func(t *testing.T){ 340 341 nlist, M, efConstruction = 10, 16, 40 342 idx0, err := NewIndexIvfHNSW(mt, 343 nlist, 344 M, 345 efConstruction, 346 ) 347 assert.Nil(t, err) 348 assert.NotNil(t, idx0) 349 assert.Equal(t, "IvfHNSW", idx0.Name()) 350 assert.EqualValues(t, "IVF_HNSW", idx0.IndexType()) 351 assert.NotNil(t, idx0.Params()) 352 assert.False(t, idx0.SupportBinary()) 353 354 }) 355 356 t.Run("invalid usage case", func(t *testing.T){ 357 358 nlist, M, efConstruction = 0, 16, 40 359 idx0, err := NewIndexIvfHNSW(mt, 360 nlist, 361 M, 362 efConstruction, 363 ) 364 assert.NotNil(t, err) 365 assert.Nil(t, idx0) 366 367 nlist, M, efConstruction = 65537, 16, 40 368 idx1, err := NewIndexIvfHNSW(mt, 369 nlist, 370 M, 371 efConstruction, 372 ) 373 assert.NotNil(t, err) 374 assert.Nil(t, idx1) 375 376 nlist, M, efConstruction = 10, 3, 40 377 idx2, err := NewIndexIvfHNSW(mt, 378 nlist, 379 M, 380 efConstruction, 381 ) 382 assert.NotNil(t, err) 383 assert.Nil(t, idx2) 384 385 nlist, M, efConstruction = 10, 65, 40 386 idx3, err := NewIndexIvfHNSW(mt, 387 nlist, 388 M, 389 efConstruction, 390 ) 391 assert.NotNil(t, err) 392 assert.Nil(t, idx3) 393 394 nlist, M, efConstruction = 10, 16, 7 395 idx4, err := NewIndexIvfHNSW(mt, 396 nlist, 397 M, 398 efConstruction, 399 ) 400 assert.NotNil(t, err) 401 assert.Nil(t, idx4) 402 403 nlist, M, efConstruction = 10, 16, 513 404 idx5, err := NewIndexIvfHNSW(mt, 405 nlist, 406 M, 407 efConstruction, 408 ) 409 assert.NotNil(t, err) 410 assert.Nil(t, idx5) 411 412 }) 413 } 414 415 func TestIndexDISKANN(t *testing.T){ 416 417 418 mt := L2 419 420 421 t.Run("valid usage case", func(t *testing.T){ 422 423 424 idx0, err := NewIndexDISKANN(mt, 425 ) 426 assert.Nil(t, err) 427 assert.NotNil(t, idx0) 428 assert.Equal(t, "DISKANN", idx0.Name()) 429 assert.EqualValues(t, "DISKANN", idx0.IndexType()) 430 assert.NotNil(t, idx0.Params()) 431 assert.False(t, idx0.SupportBinary()) 432 433 }) 434 435 t.Run("invalid usage case", func(t *testing.T){ 436 437 }) 438 } 439 440 func TestIndexAUTOINDEX(t *testing.T){ 441 442 443 mt := L2 444 445 446 t.Run("valid usage case", func(t *testing.T){ 447 448 449 idx0, err := NewIndexAUTOINDEX(mt, 450 ) 451 assert.Nil(t, err) 452 assert.NotNil(t, idx0) 453 assert.Equal(t, "AUTOINDEX", idx0.Name()) 454 assert.EqualValues(t, "AUTOINDEX", idx0.IndexType()) 455 assert.NotNil(t, idx0.Params()) 456 assert.False(t, idx0.SupportBinary()) 457 458 }) 459 460 t.Run("invalid usage case", func(t *testing.T){ 461 462 }) 463 } 464 465 func TestIndexGPUIvfFlat(t *testing.T){ 466 467 var nlist int 468 469 mt := L2 470 471 472 t.Run("valid usage case", func(t *testing.T){ 473 474 nlist = 10 475 idx0, err := NewIndexGPUIvfFlat(mt, 476 nlist, 477 ) 478 assert.Nil(t, err) 479 assert.NotNil(t, idx0) 480 assert.Equal(t, "GPUIvfFlat", idx0.Name()) 481 assert.EqualValues(t, "GPU_IVF_FLAT", idx0.IndexType()) 482 assert.NotNil(t, idx0.Params()) 483 assert.False(t, idx0.SupportBinary()) 484 485 }) 486 487 t.Run("invalid usage case", func(t *testing.T){ 488 489 nlist = 0 490 idx0, err := NewIndexGPUIvfFlat(mt, 491 nlist, 492 ) 493 assert.NotNil(t, err) 494 assert.Nil(t, idx0) 495 496 nlist = 65537 497 idx1, err := NewIndexGPUIvfFlat(mt, 498 nlist, 499 ) 500 assert.NotNil(t, err) 501 assert.Nil(t, idx1) 502 503 }) 504 } 505 506 func TestIndexGPUIvfPQ(t *testing.T){ 507 508 var nlist int 509 var m int 510 var nbits int 511 512 mt := L2 513 514 515 t.Run("valid usage case", func(t *testing.T){ 516 517 nlist, m, nbits = 10, 8, 8 518 idx0, err := NewIndexGPUIvfPQ(mt, 519 nlist, 520 m, 521 nbits, 522 ) 523 assert.Nil(t, err) 524 assert.NotNil(t, idx0) 525 assert.Equal(t, "GPUIvfPQ", idx0.Name()) 526 assert.EqualValues(t, "GPU_IVF_PQ", idx0.IndexType()) 527 assert.NotNil(t, idx0.Params()) 528 assert.False(t, idx0.SupportBinary()) 529 530 }) 531 532 t.Run("invalid usage case", func(t *testing.T){ 533 534 nlist, m, nbits = 0, 8, 8 535 idx0, err := NewIndexGPUIvfPQ(mt, 536 nlist, 537 m, 538 nbits, 539 ) 540 assert.NotNil(t, err) 541 assert.Nil(t, idx0) 542 543 nlist, m, nbits = 65537, 8, 8 544 idx1, err := NewIndexGPUIvfPQ(mt, 545 nlist, 546 m, 547 nbits, 548 ) 549 assert.NotNil(t, err) 550 assert.Nil(t, idx1) 551 552 nlist, m, nbits = 10, 8, 0 553 idx2, err := NewIndexGPUIvfPQ(mt, 554 nlist, 555 m, 556 nbits, 557 ) 558 assert.NotNil(t, err) 559 assert.Nil(t, idx2) 560 561 nlist, m, nbits = 10, 8, 65 562 idx3, err := NewIndexGPUIvfPQ(mt, 563 nlist, 564 m, 565 nbits, 566 ) 567 assert.NotNil(t, err) 568 assert.Nil(t, idx3) 569 570 }) 571 } 572 573 func TestIndexSCANN(t *testing.T){ 574 575 var nlist int 576 var with_raw_data bool 577 578 mt := L2 579 580 581 t.Run("valid usage case", func(t *testing.T){ 582 583 nlist = 100 584 idx0, err := NewIndexSCANN(mt, 585 nlist, 586 with_raw_data, 587 ) 588 assert.Nil(t, err) 589 assert.NotNil(t, idx0) 590 assert.Equal(t, "SCANN", idx0.Name()) 591 assert.EqualValues(t, "SCANN", idx0.IndexType()) 592 assert.NotNil(t, idx0.Params()) 593 assert.False(t, idx0.SupportBinary()) 594 595 with_raw_data = true 596 idx1, err := NewIndexSCANN(mt, 597 nlist, 598 with_raw_data, 599 ) 600 assert.Nil(t, err) 601 assert.NotNil(t, idx1) 602 assert.Equal(t, "SCANN", idx1.Name()) 603 assert.EqualValues(t, "SCANN", idx1.IndexType()) 604 assert.NotNil(t, idx1.Params()) 605 assert.False(t, idx1.SupportBinary()) 606 607 }) 608 609 t.Run("invalid usage case", func(t *testing.T){ 610 611 nlist = 0 612 idx0, err := NewIndexSCANN(mt, 613 nlist, 614 with_raw_data, 615 ) 616 assert.NotNil(t, err) 617 assert.Nil(t, idx0) 618 619 nlist = 65537 620 idx1, err := NewIndexSCANN(mt, 621 nlist, 622 with_raw_data, 623 ) 624 assert.NotNil(t, err) 625 assert.Nil(t, idx1) 626 627 }) 628 } 629