Skip to content

Commit 6718dae

Browse files
Kaival Parikhfacebook-github-bot
authored andcommitted
Expose IDSelectorBitmap in the C_API (#4158)
Summary: Pull Request resolved: #4158 Reviewed By: mnorris11 Differential Revision: D68901764 Pulled By: asadoughi fbshipit-source-id: 5b5abf207947a62592ea48c32870e7060956a335
1 parent 9bc4b67 commit 6718dae

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

c_api/impl/AuxIndexStructures_c.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ using faiss::DistanceComputer;
1919
using faiss::IDSelector;
2020
using faiss::IDSelectorAnd;
2121
using faiss::IDSelectorBatch;
22+
using faiss::IDSelectorBitmap;
2223
using faiss::IDSelectorNot;
2324
using faiss::IDSelectorOr;
2425
using faiss::IDSelectorRange;
@@ -119,6 +120,23 @@ int faiss_IDSelectorBatch_new(
119120
CATCH_AND_HANDLE
120121
}
121122

123+
DEFINE_DESTRUCTOR(IDSelectorBitmap)
124+
125+
DEFINE_GETTER(IDSelectorBitmap, size_t, n)
126+
DEFINE_GETTER(IDSelectorBitmap, const uint8_t*, bitmap)
127+
128+
int faiss_IDSelectorBitmap_new(
129+
FaissIDSelectorBitmap** p_sel,
130+
size_t n,
131+
const uint8_t* bitmap) {
132+
try {
133+
*p_sel = reinterpret_cast<FaissIDSelectorBitmap*>(
134+
new IDSelectorBitmap(n, bitmap));
135+
return 0;
136+
}
137+
CATCH_AND_HANDLE
138+
}
139+
122140
int faiss_IDSelectorNot_new(
123141
FaissIDSelectorNot** p_sel,
124142
const FaissIDSelector* sel) {

c_api/impl/AuxIndexStructures_c.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ int faiss_IDSelectorBatch_new(
8181
size_t n,
8282
const idx_t* indices);
8383

84+
FAISS_DECLARE_CLASS(IDSelectorBitmap)
85+
FAISS_DECLARE_DESTRUCTOR(IDSelectorBitmap)
86+
87+
FAISS_DECLARE_GETTER(IDSelectorBitmap, size_t, n)
88+
FAISS_DECLARE_GETTER(IDSelectorBitmap, const uint8_t*, bitmap)
89+
90+
int faiss_IDSelectorBitmap_new(
91+
FaissIDSelectorBitmap** p_sel,
92+
size_t n,
93+
const uint8_t* bitmap);
94+
8495
FAISS_DECLARE_CLASS(IDSelectorNot)
8596
int faiss_IDSelectorNot_new(
8697
FaissIDSelectorNot** p_sel,

0 commit comments

Comments
 (0)