Skip to content

Commit 6eedc21

Browse files
binary param related funcs
1 parent e007a6c commit 6eedc21

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

c_api/IndexBinary_c.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ DEFINE_SETTER(IndexBinary, int, verbose);
3232
DEFINE_GETTER(IndexBinaryIVF, size_t, nprobe);
3333
DEFINE_SETTER(IndexBinaryIVF, size_t, nprobe);
3434

35+
DEFINE_GETTER(IndexBinaryIVF, size_t, nlist);
36+
DEFINE_SETTER(IndexBinaryIVF, size_t, nlist);
37+
3538
DEFINE_INDEXBINARY_DOWNCAST(IndexBinaryIVF)
3639

3740
int faiss_IndexBinaryIVF_set_direct_map(
@@ -86,6 +89,26 @@ int faiss_IndexBinary_search(
8689
CATCH_AND_HANDLE
8790
}
8891

92+
int faiss_IndexBinary_search_with_params(
93+
const FaissIndexBinary* index,
94+
idx_t n,
95+
const uint8_t* x,
96+
idx_t k,
97+
const FaissSearchParameters* params,
98+
int32_t* distances,
99+
idx_t* labels) {
100+
try {
101+
reinterpret_cast<const faiss::IndexBinary*>(index)->search(
102+
n,
103+
x,
104+
k,
105+
distances,
106+
labels,
107+
reinterpret_cast<const faiss::SearchParameters*>(params));
108+
}
109+
CATCH_AND_HANDLE
110+
}
111+
89112
int faiss_IndexBinary_range_search(
90113
const FaissIndexBinary* index,
91114
idx_t n,

c_api/IndexBinary_c.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ FAISS_DECLARE_GETTER(IndexBinary, FaissMetricType, metric_type)
4747

4848
FAISS_DECLARE_GETTER_SETTER(IndexBinary, int, verbose)
4949

50+
FAISS_DECLARE_GETTER_SETTER(IndexBinaryIVF, size_t, nlist)
51+
5052
FAISS_DECLARE_GETTER_SETTER(IndexBinaryIVF, size_t, nprobe)
5153

5254
/** Perform training on a representative set of vectors
@@ -99,6 +101,27 @@ int faiss_IndexBinary_search(
99101
int32_t* distances,
100102
idx_t* labels);
101103

104+
/** query n vectors of dimension d to the index.
105+
*
106+
* return at most k vectors. If there are not enough results for a
107+
* query, the result array is padded with -1s.
108+
*
109+
* @param index opaque pointer to index object
110+
* @param x input vectors to search, size n * d
111+
* @param k number of results to return
112+
* @param params search parameters
113+
* @param distances output distances, size n*k
114+
* @param labels output labels of the NNs, size n*k
115+
*/
116+
int faiss_IndexBinary_search_with_params(
117+
const FaissIndexBinary* index,
118+
idx_t n,
119+
const uint8_t* x,
120+
idx_t k,
121+
const FaissSearchParameters* params,
122+
int32_t* distances,
123+
idx_t* labels);
124+
102125
/** query n vectors of dimension d to the index.
103126
*
104127
* return all vectors with distance < radius. Note that many

0 commit comments

Comments
 (0)