-
Notifications
You must be signed in to change notification settings - Fork 36
/
bindings.rs
2181 lines (2180 loc) · 77.1 KB
/
bindings.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* automatically generated by rust-bindgen 0.69.4 */
pub type faiss_idx_t = i64;
pub type idx_t = faiss_idx_t;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissRangeSearchResult_H {
_unused: [u8; 0],
}
pub type FaissRangeSearchResult = FaissRangeSearchResult_H;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissIDSelector_H {
_unused: [u8; 0],
}
pub type FaissIDSelector = FaissIDSelector_H;
#[doc = "< maximum inner product search"]
pub const FaissMetricType_METRIC_INNER_PRODUCT: FaissMetricType = 0;
#[doc = "< squared L2 search"]
pub const FaissMetricType_METRIC_L2: FaissMetricType = 1;
#[doc = "< L1 (aka cityblock)"]
pub const FaissMetricType_METRIC_L1: FaissMetricType = 2;
#[doc = "< infinity distance"]
pub const FaissMetricType_METRIC_Linf: FaissMetricType = 3;
#[doc = "< L_p distance, p is given by metric_arg"]
pub const FaissMetricType_METRIC_Lp: FaissMetricType = 4;
#[doc = " some additional metrics defined in scipy.spatial.distance"]
pub const FaissMetricType_METRIC_Canberra: FaissMetricType = 20;
#[doc = " some additional metrics defined in scipy.spatial.distance"]
pub const FaissMetricType_METRIC_BrayCurtis: FaissMetricType = 21;
#[doc = " some additional metrics defined in scipy.spatial.distance"]
pub const FaissMetricType_METRIC_JensenShannon: FaissMetricType = 22;
#[doc = " Some algorithms support both an inner product version and a L2 search\n version."]
pub type FaissMetricType = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissSearchParameters_H {
_unused: [u8; 0],
}
pub type FaissSearchParameters = FaissSearchParameters_H;
extern "C" {
pub fn faiss_SearchParameters_free(obj: *mut FaissSearchParameters);
}
extern "C" {
pub fn faiss_SearchParameters_new(
p_sp: *mut *mut FaissSearchParameters,
sel: *mut FaissIDSelector,
) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissIndex_H {
_unused: [u8; 0],
}
pub type FaissIndex = FaissIndex_H;
extern "C" {
pub fn faiss_Index_free(obj: *mut FaissIndex);
}
extern "C" {
pub fn faiss_Index_d(arg1: *const FaissIndex) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_Index_is_trained(arg1: *const FaissIndex) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_Index_ntotal(arg1: *const FaissIndex) -> idx_t;
}
extern "C" {
pub fn faiss_Index_metric_type(arg1: *const FaissIndex) -> FaissMetricType;
}
extern "C" {
pub fn faiss_Index_verbose(arg1: *const FaissIndex) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_Index_set_verbose(arg1: *mut FaissIndex, arg2: ::std::os::raw::c_int);
}
extern "C" {
#[doc = " Perform training on a representative set of vectors\n\n @param index opaque pointer to index object\n @param n nb of training vectors\n @param x training vectors, size n * d"]
pub fn faiss_Index_train(
index: *mut FaissIndex,
n: idx_t,
x: *const f32,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " Add n vectors of dimension d to the index.\n\n Vectors are implicitly assigned labels ntotal .. ntotal + n - 1\n This function slices the input vectors in chunks smaller than\n blocksize_add and calls add_core.\n @param index opaque pointer to index object\n @param x input matrix, size n * d"]
pub fn faiss_Index_add(
index: *mut FaissIndex,
n: idx_t,
x: *const f32,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " Same as add, but stores xids instead of sequential ids.\n\n The default implementation fails with an assertion, as it is\n not supported by all indexes.\n\n @param index opaque pointer to index object\n @param xids if non-null, ids to store for the vectors (size n)"]
pub fn faiss_Index_add_with_ids(
index: *mut FaissIndex,
n: idx_t,
x: *const f32,
xids: *const idx_t,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " query n vectors of dimension d to the index.\n\n return at most k vectors. If there are not enough results for a\n query, the result array is padded with -1s.\n\n @param index opaque pointer to index object\n @param x input vectors to search, size n * d\n @param labels output labels of the NNs, size n*k\n @param distances output pairwise distances, size n*k"]
pub fn faiss_Index_search(
index: *const FaissIndex,
n: idx_t,
x: *const f32,
k: idx_t,
distances: *mut f32,
labels: *mut idx_t,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " query n vectors of dimension d with search parameters to the index.\n\n return at most k vectors. If there are not enough results for a query,\n the result is padded with -1s.\n\n @param index opaque pointer to index object\n @param x input vectors to search, size n * d\n @param params input params to modify how search is done\n @param labels output labels of the NNs, size n*k\n @param distances output pairwise distances, size n*k"]
pub fn faiss_Index_search_with_params(
index: *const FaissIndex,
n: idx_t,
x: *const f32,
k: idx_t,
params: *const FaissSearchParameters,
distances: *mut f32,
labels: *mut idx_t,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " query n vectors of dimension d to the index.\n\n return all vectors with distance < radius. Note that many\n indexes do not implement the range_search (only the k-NN search\n is mandatory).\n\n @param index opaque pointer to index object\n @param x input vectors to search, size n * d\n @param radius search radius\n @param result result table"]
pub fn faiss_Index_range_search(
index: *const FaissIndex,
n: idx_t,
x: *const f32,
radius: f32,
result: *mut FaissRangeSearchResult,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " return the indexes of the k vectors closest to the query x.\n\n This function is identical as search but only return labels of neighbors.\n @param index opaque pointer to index object\n @param x input vectors to search, size n * d\n @param labels output labels of the NNs, size n*k"]
pub fn faiss_Index_assign(
index: *mut FaissIndex,
n: idx_t,
x: *const f32,
labels: *mut idx_t,
k: idx_t,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " removes all elements from the database.\n @param index opaque pointer to index object"]
pub fn faiss_Index_reset(index: *mut FaissIndex) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " removes IDs from the index. Not supported by all indexes\n @param index opaque pointer to index object\n @param nremove output for the number of IDs removed"]
pub fn faiss_Index_remove_ids(
index: *mut FaissIndex,
sel: *const FaissIDSelector,
n_removed: *mut usize,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " Reconstruct a stored vector (or an approximation if lossy coding)\n\n this function may not be defined for some indexes\n @param index opaque pointer to index object\n @param key id of the vector to reconstruct\n @param recons reconstructed vector (size d)"]
pub fn faiss_Index_reconstruct(
index: *const FaissIndex,
key: idx_t,
recons: *mut f32,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " Reconstruct vectors i0 to i0 + ni - 1\n\n this function may not be defined for some indexes\n @param index opaque pointer to index object\n @param recons reconstructed vector (size ni * d)"]
pub fn faiss_Index_reconstruct_n(
index: *const FaissIndex,
i0: idx_t,
ni: idx_t,
recons: *mut f32,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " Computes a residual vector after indexing encoding.\n\n The residual vector is the difference between a vector and the\n reconstruction that can be decoded from its representation in\n the index. The residual can be used for multiple-stage indexing\n methods, like IndexIVF's methods.\n\n @param index opaque pointer to index object\n @param x input vector, size d\n @param residual output residual vector, size d\n @param key encoded index, as returned by search and assign"]
pub fn faiss_Index_compute_residual(
index: *const FaissIndex,
x: *const f32,
residual: *mut f32,
key: idx_t,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " Computes a residual vector after indexing encoding.\n\n The residual vector is the difference between a vector and the\n reconstruction that can be decoded from its representation in\n the index. The residual can be used for multiple-stage indexing\n methods, like IndexIVF's methods.\n\n @param index opaque pointer to index object\n @param n number of vectors\n @param x input vector, size (n x d)\n @param residuals output residual vectors, size (n x d)\n @param keys encoded index, as returned by search and assign"]
pub fn faiss_Index_compute_residual_n(
index: *const FaissIndex,
n: idx_t,
x: *const f32,
residuals: *mut f32,
keys: *const idx_t,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " The size of the produced codes in bytes.\n\n @param index opaque pointer to index object\n @param size the returned size in bytes"]
pub fn faiss_Index_sa_code_size(
index: *const FaissIndex,
size: *mut usize,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " encode a set of vectors\n\n @param index opaque pointer to index object\n @param n number of vectors\n @param x input vectors, size n * d\n @param bytes output encoded vectors, size n * sa_code_size()"]
pub fn faiss_Index_sa_encode(
index: *const FaissIndex,
n: idx_t,
x: *const f32,
bytes: *mut u8,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " decode a set of vectors\n\n @param index opaque pointer to index object\n @param n number of vectors\n @param bytes input encoded vectors, size n * sa_code_size()\n @param x output vectors, size n * d"]
pub fn faiss_Index_sa_decode(
index: *const FaissIndex,
n: idx_t,
bytes: *const u8,
x: *mut f32,
) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissParameterRange_H {
_unused: [u8; 0],
}
pub type FaissParameterRange = FaissParameterRange_H;
extern "C" {
pub fn faiss_ParameterRange_name(
arg1: *const FaissParameterRange,
) -> *const ::std::os::raw::c_char;
}
extern "C" {
#[doc = " Getter for the values in the range. The output values are invalidated\n upon any other modification of the range."]
pub fn faiss_ParameterRange_values(
arg1: *mut FaissParameterRange,
arg2: *mut *mut f64,
arg3: *mut usize,
);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissParameterSpace_H {
_unused: [u8; 0],
}
pub type FaissParameterSpace = FaissParameterSpace_H;
extern "C" {
pub fn faiss_ParameterSpace_free(obj: *mut FaissParameterSpace);
}
extern "C" {
#[doc = " Parameter space default constructor"]
pub fn faiss_ParameterSpace_new(space: *mut *mut FaissParameterSpace) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " nb of combinations, = product of values sizes"]
pub fn faiss_ParameterSpace_n_combinations(arg1: *const FaissParameterSpace) -> usize;
}
extern "C" {
#[doc = " get string representation of the combination\n by writing it to the given character buffer.\n A buffer size of 1000 ensures that the full name is collected."]
pub fn faiss_ParameterSpace_combination_name(
arg1: *const FaissParameterSpace,
arg2: usize,
arg3: *mut ::std::os::raw::c_char,
arg4: usize,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " set a combination of parameters described by a string"]
pub fn faiss_ParameterSpace_set_index_parameters(
arg1: *const FaissParameterSpace,
arg2: *mut FaissIndex,
arg3: *const ::std::os::raw::c_char,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " set a combination of parameters on an index"]
pub fn faiss_ParameterSpace_set_index_parameters_cno(
arg1: *const FaissParameterSpace,
arg2: *mut FaissIndex,
arg3: usize,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " set one of the parameters"]
pub fn faiss_ParameterSpace_set_index_parameter(
arg1: *const FaissParameterSpace,
arg2: *mut FaissIndex,
arg3: *const ::std::os::raw::c_char,
arg4: f64,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " print a description on stdout"]
pub fn faiss_ParameterSpace_display(arg1: *const FaissParameterSpace);
}
extern "C" {
#[doc = " add a new parameter (or return it if it exists)"]
pub fn faiss_ParameterSpace_add_range(
arg1: *mut FaissParameterSpace,
arg2: *const ::std::os::raw::c_char,
arg3: *mut *mut FaissParameterRange,
) -> ::std::os::raw::c_int;
}
pub type FILE = [u64; 27usize];
extern "C" {
#[doc = " Clone an index. This is equivalent to `faiss::clone_index`"]
pub fn faiss_clone_index(
arg1: *const FaissIndex,
p_out: *mut *mut FaissIndex,
) -> ::std::os::raw::c_int;
}
#[doc = " Class for the clustering parameters. Can be passed to the\n constructor of the Clustering object."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissClusteringParameters {
#[doc = "< clustering iterations"]
pub niter: ::std::os::raw::c_int,
#[doc = "< redo clustering this many times and keep best"]
pub nredo: ::std::os::raw::c_int,
#[doc = "< (bool)"]
pub verbose: ::std::os::raw::c_int,
#[doc = "< (bool) do we want normalized centroids?"]
pub spherical: ::std::os::raw::c_int,
#[doc = "< (bool) round centroids coordinates to integer"]
pub int_centroids: ::std::os::raw::c_int,
#[doc = "< (bool) update index after each iteration?"]
pub update_index: ::std::os::raw::c_int,
#[doc = "< (bool) use the centroids provided as input and do\n< not change them during iterations"]
pub frozen_centroids: ::std::os::raw::c_int,
#[doc = "< otherwise you get a warning"]
pub min_points_per_centroid: ::std::os::raw::c_int,
#[doc = "< to limit size of dataset"]
pub max_points_per_centroid: ::std::os::raw::c_int,
#[doc = "< seed for the random number generator"]
pub seed: ::std::os::raw::c_int,
#[doc = "< how many vectors at a time to decode"]
pub decode_block_size: usize,
}
#[test]
fn bindgen_test_layout_FaissClusteringParameters() {
const UNINIT: ::std::mem::MaybeUninit<FaissClusteringParameters> =
::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<FaissClusteringParameters>(),
48usize,
concat!("Size of: ", stringify!(FaissClusteringParameters))
);
assert_eq!(
::std::mem::align_of::<FaissClusteringParameters>(),
8usize,
concat!("Alignment of ", stringify!(FaissClusteringParameters))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).niter) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(FaissClusteringParameters),
"::",
stringify!(niter)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).nredo) as usize - ptr as usize },
4usize,
concat!(
"Offset of field: ",
stringify!(FaissClusteringParameters),
"::",
stringify!(nredo)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).verbose) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(FaissClusteringParameters),
"::",
stringify!(verbose)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).spherical) as usize - ptr as usize },
12usize,
concat!(
"Offset of field: ",
stringify!(FaissClusteringParameters),
"::",
stringify!(spherical)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).int_centroids) as usize - ptr as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(FaissClusteringParameters),
"::",
stringify!(int_centroids)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).update_index) as usize - ptr as usize },
20usize,
concat!(
"Offset of field: ",
stringify!(FaissClusteringParameters),
"::",
stringify!(update_index)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).frozen_centroids) as usize - ptr as usize },
24usize,
concat!(
"Offset of field: ",
stringify!(FaissClusteringParameters),
"::",
stringify!(frozen_centroids)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).min_points_per_centroid) as usize - ptr as usize },
28usize,
concat!(
"Offset of field: ",
stringify!(FaissClusteringParameters),
"::",
stringify!(min_points_per_centroid)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).max_points_per_centroid) as usize - ptr as usize },
32usize,
concat!(
"Offset of field: ",
stringify!(FaissClusteringParameters),
"::",
stringify!(max_points_per_centroid)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).seed) as usize - ptr as usize },
36usize,
concat!(
"Offset of field: ",
stringify!(FaissClusteringParameters),
"::",
stringify!(seed)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).decode_block_size) as usize - ptr as usize },
40usize,
concat!(
"Offset of field: ",
stringify!(FaissClusteringParameters),
"::",
stringify!(decode_block_size)
)
);
}
extern "C" {
#[doc = " Sets the ClusteringParameters object with reasonable defaults"]
pub fn faiss_ClusteringParameters_init(params: *mut FaissClusteringParameters);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissClustering_H {
_unused: [u8; 0],
}
pub type FaissClustering = FaissClustering_H;
extern "C" {
pub fn faiss_Clustering_niter(arg1: *const FaissClustering) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_Clustering_nredo(arg1: *const FaissClustering) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_Clustering_verbose(arg1: *const FaissClustering) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_Clustering_spherical(arg1: *const FaissClustering) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_Clustering_int_centroids(arg1: *const FaissClustering) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_Clustering_update_index(arg1: *const FaissClustering) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_Clustering_frozen_centroids(arg1: *const FaissClustering)
-> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_Clustering_min_points_per_centroid(
arg1: *const FaissClustering,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_Clustering_max_points_per_centroid(
arg1: *const FaissClustering,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_Clustering_seed(arg1: *const FaissClustering) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_Clustering_decode_block_size(arg1: *const FaissClustering) -> usize;
}
extern "C" {
pub fn faiss_Clustering_d(arg1: *const FaissClustering) -> usize;
}
extern "C" {
pub fn faiss_Clustering_k(arg1: *const FaissClustering) -> usize;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissClusteringIterationStats_H {
_unused: [u8; 0],
}
pub type FaissClusteringIterationStats = FaissClusteringIterationStats_H;
extern "C" {
pub fn faiss_ClusteringIterationStats_obj(arg1: *const FaissClusteringIterationStats) -> f32;
}
extern "C" {
pub fn faiss_ClusteringIterationStats_time(arg1: *const FaissClusteringIterationStats) -> f64;
}
extern "C" {
pub fn faiss_ClusteringIterationStats_time_search(
arg1: *const FaissClusteringIterationStats,
) -> f64;
}
extern "C" {
pub fn faiss_ClusteringIterationStats_imbalance_factor(
arg1: *const FaissClusteringIterationStats,
) -> f64;
}
extern "C" {
pub fn faiss_ClusteringIterationStats_nsplit(
arg1: *const FaissClusteringIterationStats,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " getter for centroids (size = k * d)"]
pub fn faiss_Clustering_centroids(
clustering: *mut FaissClustering,
centroids: *mut *mut f32,
size: *mut usize,
);
}
extern "C" {
#[doc = " getter for iteration stats"]
pub fn faiss_Clustering_iteration_stats(
clustering: *mut FaissClustering,
iteration_stats: *mut *mut FaissClusteringIterationStats,
size: *mut usize,
);
}
extern "C" {
#[doc = " the only mandatory parameters are k and d"]
pub fn faiss_Clustering_new(
p_clustering: *mut *mut FaissClustering,
d: ::std::os::raw::c_int,
k: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_Clustering_new_with_params(
p_clustering: *mut *mut FaissClustering,
d: ::std::os::raw::c_int,
k: ::std::os::raw::c_int,
cp: *const FaissClusteringParameters,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_Clustering_train(
clustering: *mut FaissClustering,
n: idx_t,
x: *const f32,
index: *mut FaissIndex,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_Clustering_free(clustering: *mut FaissClustering);
}
extern "C" {
#[doc = " simplified interface\n\n @param d dimension of the data\n @param n nb of training vectors\n @param k nb of output centroids\n @param x training set (size n * d)\n @param centroids output centroids (size k * d)\n @param q_error final quantization error\n @return error code"]
pub fn faiss_kmeans_clustering(
d: usize,
n: usize,
k: usize,
x: *const f32,
centroids: *mut f32,
q_error: *mut f32,
) -> ::std::os::raw::c_int;
}
#[doc = " No error"]
pub const FaissErrorCode_OK: FaissErrorCode = 0;
#[doc = " Any exception other than Faiss or standard C++ library exceptions"]
pub const FaissErrorCode_UNKNOWN_EXCEPT: FaissErrorCode = -1;
#[doc = " Faiss library exception"]
pub const FaissErrorCode_FAISS_EXCEPT: FaissErrorCode = -2;
#[doc = " Standard C++ library exception"]
pub const FaissErrorCode_STD_EXCEPT: FaissErrorCode = -4;
#[doc = " An error code which depends on the exception thrown from the previous\n operation. See `faiss_get_last_error` to retrieve the error message."]
pub type FaissErrorCode = ::std::os::raw::c_int;
extern "C" {
#[doc = " Get the error message of the last failed operation performed by Faiss.\n The given pointer is only invalid until another Faiss function is\n called."]
pub fn faiss_get_last_error() -> *const ::std::os::raw::c_char;
}
extern "C" {
pub fn faiss_RangeSearchResult_nq(arg1: *const FaissRangeSearchResult) -> usize;
}
extern "C" {
pub fn faiss_RangeSearchResult_new(
p_rsr: *mut *mut FaissRangeSearchResult,
nq: idx_t,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_RangeSearchResult_new_with(
p_rsr: *mut *mut FaissRangeSearchResult,
nq: idx_t,
alloc_lims: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " called when lims contains the nb of elements result entries\n for each query"]
pub fn faiss_RangeSearchResult_do_allocation(
rsr: *mut FaissRangeSearchResult,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_RangeSearchResult_free(obj: *mut FaissRangeSearchResult);
}
extern "C" {
pub fn faiss_RangeSearchResult_buffer_size(arg1: *const FaissRangeSearchResult) -> usize;
}
extern "C" {
#[doc = " getter for lims: size (nq + 1)"]
pub fn faiss_RangeSearchResult_lims(rsr: *mut FaissRangeSearchResult, lims: *mut *mut usize);
}
extern "C" {
#[doc = " getter for labels and respective distances (not sorted):\n result for query i is labels[lims[i]:lims[i+1]]"]
pub fn faiss_RangeSearchResult_labels(
rsr: *mut FaissRangeSearchResult,
labels: *mut *mut idx_t,
distances: *mut *mut f32,
);
}
extern "C" {
pub fn faiss_IDSelector_free(obj: *mut FaissIDSelector);
}
extern "C" {
#[doc = " Encapsulates a set of ids to remove."]
pub fn faiss_IDSelector_is_member(
sel: *const FaissIDSelector,
id: idx_t,
) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissIDSelectorRange_H {
_unused: [u8; 0],
}
pub type FaissIDSelectorRange = FaissIDSelectorRange_H;
extern "C" {
pub fn faiss_IDSelectorRange_free(obj: *mut FaissIDSelectorRange);
}
extern "C" {
pub fn faiss_IDSelectorRange_imin(arg1: *const FaissIDSelectorRange) -> idx_t;
}
extern "C" {
pub fn faiss_IDSelectorRange_imax(arg1: *const FaissIDSelectorRange) -> idx_t;
}
extern "C" {
#[doc = " remove ids between [imni, imax)"]
pub fn faiss_IDSelectorRange_new(
p_sel: *mut *mut FaissIDSelectorRange,
imin: idx_t,
imax: idx_t,
) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissIDSelectorBatch_H {
_unused: [u8; 0],
}
pub type FaissIDSelectorBatch = FaissIDSelectorBatch_H;
extern "C" {
pub fn faiss_IDSelectorBatch_nbits(arg1: *const FaissIDSelectorBatch) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_IDSelectorBatch_mask(arg1: *const FaissIDSelectorBatch) -> idx_t;
}
extern "C" {
#[doc = " Remove ids from a set. Repetitions of ids in the indices set\n passed to the constructor does not hurt performance. The hash\n function used for the bloom filter and GCC's implementation of\n unordered_set are just the least significant bits of the id. This\n works fine for random ids or ids in sequences but will produce many\n hash collisions if lsb's are always the same"]
pub fn faiss_IDSelectorBatch_new(
p_sel: *mut *mut FaissIDSelectorBatch,
n: usize,
indices: *const idx_t,
) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissIDSelectorNot_H {
_unused: [u8; 0],
}
pub type FaissIDSelectorNot = FaissIDSelectorNot_H;
extern "C" {
pub fn faiss_IDSelectorNot_new(
p_sel: *mut *mut FaissIDSelectorNot,
sel: *const FaissIDSelector,
) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissIDSelectorAnd_H {
_unused: [u8; 0],
}
pub type FaissIDSelectorAnd = FaissIDSelectorAnd_H;
extern "C" {
pub fn faiss_IDSelectorAnd_new(
p_sel: *mut *mut FaissIDSelectorAnd,
lhs_sel: *const FaissIDSelector,
rhs_sel: *const FaissIDSelector,
) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissIDSelectorOr_H {
_unused: [u8; 0],
}
pub type FaissIDSelectorOr = FaissIDSelectorOr_H;
extern "C" {
pub fn faiss_IDSelectorOr_new(
p_sel: *mut *mut FaissIDSelectorOr,
lhs_sel: *const FaissIDSelector,
rhs_sel: *const FaissIDSelector,
) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissIDSelectorXOr_H {
_unused: [u8; 0],
}
pub type FaissIDSelectorXOr = FaissIDSelectorXOr_H;
extern "C" {
pub fn faiss_IDSelectorXOr_new(
p_sel: *mut *mut FaissIDSelectorXOr,
lhs_sel: *const FaissIDSelector,
rhs_sel: *const FaissIDSelector,
) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissBufferList_H {
_unused: [u8; 0],
}
pub type FaissBufferList = FaissBufferList_H;
extern "C" {
pub fn faiss_BufferList_free(obj: *mut FaissBufferList);
}
extern "C" {
pub fn faiss_BufferList_buffer_size(arg1: *const FaissBufferList) -> usize;
}
extern "C" {
pub fn faiss_BufferList_wp(arg1: *const FaissBufferList) -> usize;
}
#[doc = " List of temporary buffers used to store results before they are\n copied to the RangeSearchResult object."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissBuffer {
pub ids: *mut idx_t,
pub dis: *mut f32,
}
#[test]
fn bindgen_test_layout_FaissBuffer() {
const UNINIT: ::std::mem::MaybeUninit<FaissBuffer> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<FaissBuffer>(),
16usize,
concat!("Size of: ", stringify!(FaissBuffer))
);
assert_eq!(
::std::mem::align_of::<FaissBuffer>(),
8usize,
concat!("Alignment of ", stringify!(FaissBuffer))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).ids) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(FaissBuffer),
"::",
stringify!(ids)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).dis) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(FaissBuffer),
"::",
stringify!(dis)
)
);
}
extern "C" {
pub fn faiss_BufferList_append_buffer(bl: *mut FaissBufferList) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_BufferList_new(
p_bl: *mut *mut FaissBufferList,
buffer_size: usize,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_BufferList_add(
bl: *mut FaissBufferList,
id: idx_t,
dis: f32,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " copy elemnts ofs:ofs+n-1 seen as linear data in the buffers to\n tables dest_ids, dest_dis"]
pub fn faiss_BufferList_copy_range(
bl: *mut FaissBufferList,
ofs: usize,
n: usize,
dest_ids: *mut idx_t,
dest_dis: *mut f32,
) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissRangeSearchPartialResult_H {
_unused: [u8; 0],
}
pub type FaissRangeSearchPartialResult = FaissRangeSearchPartialResult_H;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissRangeQueryResult_H {
_unused: [u8; 0],
}
pub type FaissRangeQueryResult = FaissRangeQueryResult_H;
extern "C" {
pub fn faiss_RangeQueryResult_qno(arg1: *const FaissRangeQueryResult) -> idx_t;
}
extern "C" {
pub fn faiss_RangeQueryResult_nres(arg1: *const FaissRangeQueryResult) -> usize;
}
extern "C" {
pub fn faiss_RangeQueryResult_pres(
arg1: *const FaissRangeQueryResult,
) -> *mut FaissRangeSearchPartialResult;
}
extern "C" {
#[doc = " result structure for a single query"]
pub fn faiss_RangeQueryResult_add(
qr: *mut FaissRangeQueryResult,
dis: f32,
id: idx_t,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_RangeSearchPartialResult_res(
arg1: *const FaissRangeSearchPartialResult,
) -> *mut FaissRangeSearchResult;
}
extern "C" {
pub fn faiss_RangeSearchPartialResult_new(
p_res: *mut *mut FaissRangeSearchPartialResult,
res_in: *mut FaissRangeSearchResult,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_RangeSearchPartialResult_finalize(
res: *mut FaissRangeSearchPartialResult,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " called by range_search before do_allocation"]
pub fn faiss_RangeSearchPartialResult_set_lims(
res: *mut FaissRangeSearchPartialResult,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_RangeSearchPartialResult_new_result(
res: *mut FaissRangeSearchPartialResult,
qno: idx_t,
qr: *mut *mut FaissRangeQueryResult,
) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissDistanceComputer_H {
_unused: [u8; 0],
}
pub type FaissDistanceComputer = FaissDistanceComputer_H;
extern "C" {
#[doc = " called before computing distances"]
pub fn faiss_DistanceComputer_set_query(
dc: *mut FaissDistanceComputer,
x: *const f32,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " Compute distance of vector i to current query.\n This function corresponds to the function call operator:\n DistanceComputer::operator()"]
pub fn faiss_DistanceComputer_vector_to_query_dis(
dc: *mut FaissDistanceComputer,
i: idx_t,
qd: *mut f32,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " compute distance between two stored vectors"]
pub fn faiss_DistanceComputer_symmetric_dis(
dc: *mut FaissDistanceComputer,
i: idx_t,
j: idx_t,
vd: *mut f32,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_DistanceComputer_free(obj: *mut FaissDistanceComputer);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FaissIndexBinary_H {
_unused: [u8; 0],
}
pub type FaissIndexBinary = FaissIndexBinary_H;
extern "C" {
pub fn faiss_IndexBinary_free(obj: *mut FaissIndexBinary);
}
extern "C" {
pub fn faiss_IndexBinary_d(arg1: *const FaissIndexBinary) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_IndexBinary_is_trained(arg1: *const FaissIndexBinary) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_IndexBinary_ntotal(arg1: *const FaissIndexBinary) -> idx_t;
}
extern "C" {
pub fn faiss_IndexBinary_metric_type(arg1: *const FaissIndexBinary) -> FaissMetricType;
}
extern "C" {
pub fn faiss_IndexBinary_verbose(arg1: *const FaissIndexBinary) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn faiss_IndexBinary_set_verbose(arg1: *mut FaissIndexBinary, arg2: ::std::os::raw::c_int);
}
extern "C" {
#[doc = " Perform training on a representative set of vectors\n\n @param index opaque pointer to index object\n @param n nb of training vectors\n @param x training vectors, size n * d"]
pub fn faiss_IndexBinary_train(
index: *mut FaissIndexBinary,
n: idx_t,
x: *const u8,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " Add n vectors of dimension d to the index.\n\n Vectors are implicitly assigned labels ntotal .. ntotal + n - 1\n This function slices the input vectors in chunks smaller than\n blocksize_add and calls add_core.\n @param index opaque pointer to index object\n @param x input matrix, size n * d"]
pub fn faiss_IndexBinary_add(
index: *mut FaissIndexBinary,
n: idx_t,
x: *const u8,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " Same as add, but stores xids instead of sequential ids.\n\n The default implementation fails with an assertion, as it is\n not supported by all indexes.\n\n @param index opaque pointer to index object\n @param xids if non-null, ids to store for the vectors (size n)"]
pub fn faiss_IndexBinary_add_with_ids(
index: *mut FaissIndexBinary,
n: idx_t,
x: *const u8,
xids: *const idx_t,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " query n vectors of dimension d to the index.\n\n return at most k vectors. If there are not enough results for a\n query, the result array is padded with -1s.\n\n @param index opaque pointer to index object\n @param x input vectors to search, size n * d\n @param labels output labels of the NNs, size n*k\n @param distances output pairwise distances, size n*k"]
pub fn faiss_IndexBinary_search(
index: *const FaissIndexBinary,
n: idx_t,
x: *const u8,
k: idx_t,
distances: *mut i32,
labels: *mut idx_t,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " query n vectors of dimension d to the index.\n\n return all vectors with distance < radius. Note that many\n indexes do not implement the range_search (only the k-NN search\n is mandatory).\n\n @param index opaque pointer to index object\n @param x input vectors to search, size n * d\n @param radius search radius\n @param result result table"]
pub fn faiss_IndexBinary_range_search(
index: *const FaissIndexBinary,
n: idx_t,
x: *const u8,
radius: ::std::os::raw::c_int,
result: *mut FaissRangeSearchResult,