github.com/milvus-io/milvus-sdk-go/v2@v2.4.1/entity/indexes_search_param_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 TestIndexFlatSearchParam(t *testing.T) {
    14  	
    15  
    16  	t.Run("valid usage case", func(t *testing.T){
    17  		
    18  		
    19  		idx0, err := NewIndexFlatSearchParam(
    20  		)
    21  		assert.Nil(t, err)
    22  		assert.NotNil(t, idx0)
    23  		assert.NotNil(t, idx0.Params())
    24  		
    25  	})
    26  	
    27  }
    28  
    29  func TestIndexBinFlatSearchParam(t *testing.T) {
    30  	
    31  	var nprobe int
    32  
    33  	t.Run("valid usage case", func(t *testing.T){
    34  		
    35  		nprobe = 10
    36  		idx0, err := NewIndexBinFlatSearchParam(
    37  			nprobe,
    38  		)
    39  		assert.Nil(t, err)
    40  		assert.NotNil(t, idx0)
    41  		assert.NotNil(t, idx0.Params())
    42  		
    43  	})
    44  	
    45  	t.Run("invalid usage case", func(t *testing.T){
    46  		
    47  		nprobe = 0
    48  		idx0, err := NewIndexBinFlatSearchParam(
    49  			nprobe,
    50  		)
    51  		assert.NotNil(t, err)
    52  		assert.Nil(t, idx0)
    53  		
    54  		nprobe = 65537
    55  		idx1, err := NewIndexBinFlatSearchParam(
    56  			nprobe,
    57  		)
    58  		assert.NotNil(t, err)
    59  		assert.Nil(t, idx1)
    60  		
    61  	})
    62  	
    63  }
    64  
    65  func TestIndexIvfFlatSearchParam(t *testing.T) {
    66  	
    67  	var nprobe int
    68  
    69  	t.Run("valid usage case", func(t *testing.T){
    70  		
    71  		nprobe = 10
    72  		idx0, err := NewIndexIvfFlatSearchParam(
    73  			nprobe,
    74  		)
    75  		assert.Nil(t, err)
    76  		assert.NotNil(t, idx0)
    77  		assert.NotNil(t, idx0.Params())
    78  		
    79  	})
    80  	
    81  	t.Run("invalid usage case", func(t *testing.T){
    82  		
    83  		nprobe = 0
    84  		idx0, err := NewIndexIvfFlatSearchParam(
    85  			nprobe,
    86  		)
    87  		assert.NotNil(t, err)
    88  		assert.Nil(t, idx0)
    89  		
    90  		nprobe = 65537
    91  		idx1, err := NewIndexIvfFlatSearchParam(
    92  			nprobe,
    93  		)
    94  		assert.NotNil(t, err)
    95  		assert.Nil(t, idx1)
    96  		
    97  	})
    98  	
    99  }
   100  
   101  func TestIndexBinIvfFlatSearchParam(t *testing.T) {
   102  	
   103  	var nprobe int
   104  
   105  	t.Run("valid usage case", func(t *testing.T){
   106  		
   107  		nprobe = 10
   108  		idx0, err := NewIndexBinIvfFlatSearchParam(
   109  			nprobe,
   110  		)
   111  		assert.Nil(t, err)
   112  		assert.NotNil(t, idx0)
   113  		assert.NotNil(t, idx0.Params())
   114  		
   115  	})
   116  	
   117  	t.Run("invalid usage case", func(t *testing.T){
   118  		
   119  		nprobe = 0
   120  		idx0, err := NewIndexBinIvfFlatSearchParam(
   121  			nprobe,
   122  		)
   123  		assert.NotNil(t, err)
   124  		assert.Nil(t, idx0)
   125  		
   126  		nprobe = 65537
   127  		idx1, err := NewIndexBinIvfFlatSearchParam(
   128  			nprobe,
   129  		)
   130  		assert.NotNil(t, err)
   131  		assert.Nil(t, idx1)
   132  		
   133  	})
   134  	
   135  }
   136  
   137  func TestIndexIvfSQ8SearchParam(t *testing.T) {
   138  	
   139  	var nprobe int
   140  
   141  	t.Run("valid usage case", func(t *testing.T){
   142  		
   143  		nprobe = 10
   144  		idx0, err := NewIndexIvfSQ8SearchParam(
   145  			nprobe,
   146  		)
   147  		assert.Nil(t, err)
   148  		assert.NotNil(t, idx0)
   149  		assert.NotNil(t, idx0.Params())
   150  		
   151  	})
   152  	
   153  	t.Run("invalid usage case", func(t *testing.T){
   154  		
   155  		nprobe = 0
   156  		idx0, err := NewIndexIvfSQ8SearchParam(
   157  			nprobe,
   158  		)
   159  		assert.NotNil(t, err)
   160  		assert.Nil(t, idx0)
   161  		
   162  		nprobe = 65537
   163  		idx1, err := NewIndexIvfSQ8SearchParam(
   164  			nprobe,
   165  		)
   166  		assert.NotNil(t, err)
   167  		assert.Nil(t, idx1)
   168  		
   169  	})
   170  	
   171  }
   172  
   173  func TestIndexIvfPQSearchParam(t *testing.T) {
   174  	
   175  	var nprobe int
   176  
   177  	t.Run("valid usage case", func(t *testing.T){
   178  		
   179  		nprobe = 10
   180  		idx0, err := NewIndexIvfPQSearchParam(
   181  			nprobe,
   182  		)
   183  		assert.Nil(t, err)
   184  		assert.NotNil(t, idx0)
   185  		assert.NotNil(t, idx0.Params())
   186  		
   187  	})
   188  	
   189  	t.Run("invalid usage case", func(t *testing.T){
   190  		
   191  		nprobe = 0
   192  		idx0, err := NewIndexIvfPQSearchParam(
   193  			nprobe,
   194  		)
   195  		assert.NotNil(t, err)
   196  		assert.Nil(t, idx0)
   197  		
   198  		nprobe = 65537
   199  		idx1, err := NewIndexIvfPQSearchParam(
   200  			nprobe,
   201  		)
   202  		assert.NotNil(t, err)
   203  		assert.Nil(t, idx1)
   204  		
   205  	})
   206  	
   207  }
   208  
   209  func TestIndexHNSWSearchParam(t *testing.T) {
   210  	
   211  	var ef int
   212  
   213  	t.Run("valid usage case", func(t *testing.T){
   214  		
   215  		ef = 16
   216  		idx0, err := NewIndexHNSWSearchParam(
   217  			ef,
   218  		)
   219  		assert.Nil(t, err)
   220  		assert.NotNil(t, idx0)
   221  		assert.NotNil(t, idx0.Params())
   222  		
   223  	})
   224  	
   225  	t.Run("invalid usage case", func(t *testing.T){
   226  		
   227  		ef = 0
   228  		idx0, err := NewIndexHNSWSearchParam(
   229  			ef,
   230  		)
   231  		assert.NotNil(t, err)
   232  		assert.Nil(t, idx0)
   233  		
   234  		ef = 32769
   235  		idx1, err := NewIndexHNSWSearchParam(
   236  			ef,
   237  		)
   238  		assert.NotNil(t, err)
   239  		assert.Nil(t, idx1)
   240  		
   241  	})
   242  	
   243  }
   244  
   245  func TestIndexIvfHNSWSearchParam(t *testing.T) {
   246  	
   247  	var nprobe int
   248  	var ef int
   249  
   250  	t.Run("valid usage case", func(t *testing.T){
   251  		
   252  		nprobe, ef = 10, 16
   253  		idx0, err := NewIndexIvfHNSWSearchParam(
   254  			nprobe,
   255  			ef,
   256  		)
   257  		assert.Nil(t, err)
   258  		assert.NotNil(t, idx0)
   259  		assert.NotNil(t, idx0.Params())
   260  		
   261  	})
   262  	
   263  	t.Run("invalid usage case", func(t *testing.T){
   264  		
   265  		nprobe, ef = 0, 16
   266  		idx0, err := NewIndexIvfHNSWSearchParam(
   267  			nprobe,
   268  			ef,
   269  		)
   270  		assert.NotNil(t, err)
   271  		assert.Nil(t, idx0)
   272  		
   273  		nprobe, ef = 65537, 16
   274  		idx1, err := NewIndexIvfHNSWSearchParam(
   275  			nprobe,
   276  			ef,
   277  		)
   278  		assert.NotNil(t, err)
   279  		assert.Nil(t, idx1)
   280  		
   281  		nprobe, ef = 10, 0
   282  		idx2, err := NewIndexIvfHNSWSearchParam(
   283  			nprobe,
   284  			ef,
   285  		)
   286  		assert.NotNil(t, err)
   287  		assert.Nil(t, idx2)
   288  		
   289  		nprobe, ef = 10, 32769
   290  		idx3, err := NewIndexIvfHNSWSearchParam(
   291  			nprobe,
   292  			ef,
   293  		)
   294  		assert.NotNil(t, err)
   295  		assert.Nil(t, idx3)
   296  		
   297  	})
   298  	
   299  }
   300  
   301  func TestIndexDISKANNSearchParam(t *testing.T) {
   302  	
   303  	var search_list int
   304  
   305  	t.Run("valid usage case", func(t *testing.T){
   306  		
   307  		search_list = 30
   308  		idx0, err := NewIndexDISKANNSearchParam(
   309  			search_list,
   310  		)
   311  		assert.Nil(t, err)
   312  		assert.NotNil(t, idx0)
   313  		assert.NotNil(t, idx0.Params())
   314  		
   315  	})
   316  	
   317  	t.Run("invalid usage case", func(t *testing.T){
   318  		
   319  		search_list = 0
   320  		idx0, err := NewIndexDISKANNSearchParam(
   321  			search_list,
   322  		)
   323  		assert.NotNil(t, err)
   324  		assert.Nil(t, idx0)
   325  		
   326  		search_list = 65537
   327  		idx1, err := NewIndexDISKANNSearchParam(
   328  			search_list,
   329  		)
   330  		assert.NotNil(t, err)
   331  		assert.Nil(t, idx1)
   332  		
   333  	})
   334  	
   335  }
   336  
   337  func TestIndexAUTOINDEXSearchParam(t *testing.T) {
   338  	
   339  	var level int
   340  
   341  	t.Run("valid usage case", func(t *testing.T){
   342  		
   343  		level = 1
   344  		idx0, err := NewIndexAUTOINDEXSearchParam(
   345  			level,
   346  		)
   347  		assert.Nil(t, err)
   348  		assert.NotNil(t, idx0)
   349  		assert.NotNil(t, idx0.Params())
   350  		
   351  	})
   352  	
   353  	t.Run("invalid usage case", func(t *testing.T){
   354  		
   355  		level = 0
   356  		idx0, err := NewIndexAUTOINDEXSearchParam(
   357  			level,
   358  		)
   359  		assert.NotNil(t, err)
   360  		assert.Nil(t, idx0)
   361  		
   362  		level = -1
   363  		idx1, err := NewIndexAUTOINDEXSearchParam(
   364  			level,
   365  		)
   366  		assert.NotNil(t, err)
   367  		assert.Nil(t, idx1)
   368  		
   369  	})
   370  	
   371  }
   372  
   373  func TestIndexGPUIvfFlatSearchParam(t *testing.T) {
   374  	
   375  	var nprobe int
   376  
   377  	t.Run("valid usage case", func(t *testing.T){
   378  		
   379  		nprobe = 10
   380  		idx0, err := NewIndexGPUIvfFlatSearchParam(
   381  			nprobe,
   382  		)
   383  		assert.Nil(t, err)
   384  		assert.NotNil(t, idx0)
   385  		assert.NotNil(t, idx0.Params())
   386  		
   387  	})
   388  	
   389  	t.Run("invalid usage case", func(t *testing.T){
   390  		
   391  		nprobe = 0
   392  		idx0, err := NewIndexGPUIvfFlatSearchParam(
   393  			nprobe,
   394  		)
   395  		assert.NotNil(t, err)
   396  		assert.Nil(t, idx0)
   397  		
   398  		nprobe = 65537
   399  		idx1, err := NewIndexGPUIvfFlatSearchParam(
   400  			nprobe,
   401  		)
   402  		assert.NotNil(t, err)
   403  		assert.Nil(t, idx1)
   404  		
   405  	})
   406  	
   407  }
   408  
   409  func TestIndexGPUIvfPQSearchParam(t *testing.T) {
   410  	
   411  	var nprobe int
   412  
   413  	t.Run("valid usage case", func(t *testing.T){
   414  		
   415  		nprobe = 10
   416  		idx0, err := NewIndexGPUIvfPQSearchParam(
   417  			nprobe,
   418  		)
   419  		assert.Nil(t, err)
   420  		assert.NotNil(t, idx0)
   421  		assert.NotNil(t, idx0.Params())
   422  		
   423  	})
   424  	
   425  	t.Run("invalid usage case", func(t *testing.T){
   426  		
   427  		nprobe = 0
   428  		idx0, err := NewIndexGPUIvfPQSearchParam(
   429  			nprobe,
   430  		)
   431  		assert.NotNil(t, err)
   432  		assert.Nil(t, idx0)
   433  		
   434  		nprobe = 65537
   435  		idx1, err := NewIndexGPUIvfPQSearchParam(
   436  			nprobe,
   437  		)
   438  		assert.NotNil(t, err)
   439  		assert.Nil(t, idx1)
   440  		
   441  	})
   442  	
   443  }
   444  
   445  func TestIndexSCANNSearchParam(t *testing.T) {
   446  	
   447  	var nprobe int
   448  	var reorder_k int
   449  
   450  	t.Run("valid usage case", func(t *testing.T){
   451  		
   452  		nprobe, reorder_k = 10, 200
   453  		idx0, err := NewIndexSCANNSearchParam(
   454  			nprobe,
   455  			reorder_k,
   456  		)
   457  		assert.Nil(t, err)
   458  		assert.NotNil(t, idx0)
   459  		assert.NotNil(t, idx0.Params())
   460  		
   461  	})
   462  	
   463  	t.Run("invalid usage case", func(t *testing.T){
   464  		
   465  		nprobe, reorder_k = 0, 200
   466  		idx0, err := NewIndexSCANNSearchParam(
   467  			nprobe,
   468  			reorder_k,
   469  		)
   470  		assert.NotNil(t, err)
   471  		assert.Nil(t, idx0)
   472  		
   473  		nprobe, reorder_k = 65537, 200
   474  		idx1, err := NewIndexSCANNSearchParam(
   475  			nprobe,
   476  			reorder_k,
   477  		)
   478  		assert.NotNil(t, err)
   479  		assert.Nil(t, idx1)
   480  		
   481  		nprobe, reorder_k = 10, -1
   482  		idx2, err := NewIndexSCANNSearchParam(
   483  			nprobe,
   484  			reorder_k,
   485  		)
   486  		assert.NotNil(t, err)
   487  		assert.Nil(t, idx2)
   488  		
   489  	})
   490  	
   491  }
   492