13 #ifndef FAISS_AUX_INDEX_STRUCTURES_H
14 #define FAISS_AUX_INDEX_STRUCTURES_H
19 #include <unordered_set>
56 virtual bool is_member (idx_t
id)
const = 0;
67 bool is_member(idx_t
id)
const override;
80 std::unordered_set<idx_t> set;
82 typedef unsigned char uint8_t;
83 std::vector<uint8_t> bloom;
88 bool is_member(idx_t
id)
const override;
115 std::vector<Buffer> buffers;
126 void add (idx_t
id,
float dis);
131 idx_t * dest_ids,
float *dest_dis);
145 void add (
float dis, idx_t
id);
174 static void merge (std::vector <RangeSearchPartialResult *> &
175 partial_results,
bool do_delete=
true);
188 virtual size_t operator()(
189 void *ptr,
size_t size,
size_t nitems) = 0;
192 virtual int fileno ();
202 virtual size_t operator()(
203 const void *ptr,
size_t size,
size_t nitems) = 0;
206 virtual int fileno ();
213 std::vector<uint8_t> data;
215 size_t operator()(
void *ptr,
size_t size,
size_t nitems)
override;
219 std::vector<uint8_t> data;
220 size_t operator()(
const void *ptr,
size_t size,
size_t nitems)
override;
235 virtual void set_query(
const float *x) = 0;
251 virtual bool want_interrupt () = 0;
254 static std::unique_ptr<InterruptCallback> instance;
261 static void check ();
virtual float symmetric_dis(idx_t i, idx_t j)=0
compute distance between two stored vectors
std::vector< RangeQueryResult > queries
query ids + nb of results per query.
virtual void set_query(const float *x)=0
called before computing distances
result structure for a single query
void append_buffer()
create a new buffer
void copy_range(size_t ofs, size_t n, idx_t *dest_ids, float *dest_dis)
void set_lims()
called by range_search before do_allocation
virtual float operator()(idx_t i)=0
compute distance of vector i to current query
RangeSearchResult(idx_t nq, bool alloc_lims=true)
lims must be allocated on input to range_search.
long idx_t
all indices are this type
size_t wp
write pointer in the last buffer.
float * distances
corresponding distances (not sorted)
void add(idx_t id, float dis)
add one result, possibly appending a new buffer if needed
virtual void do_allocation()
the entries in the buffers are split per query
static bool is_interrupted()
void copy_result(bool incremental=false)
called by range_search after do_allocation
static void merge(std::vector< RangeSearchPartialResult * > &partial_results, bool do_delete=true)
RangeQueryResult & new_result(idx_t qno)
begin a new result
size_t buffer_size
size of the result buffers used
static size_t get_period_hint(size_t flops)
size_t * lims
size (nq + 1)
void add(float dis, idx_t id)
called by search function to report a new result
idx_t * labels
result for query i is labels[lims[i]:lims[i+1]]
RangeSearchPartialResult(RangeSearchResult *res_in)
eventually the result will be stored in res_in