12 #ifndef FAISS_INDEX_IVF_H
13 #define FAISS_INDEX_IVF_H
20 #include "Clustering.h"
55 std::vector < std::vector<long> >
ids;
58 std::vector < std::vector<uint8_t> > codes;
62 std::vector <long> direct_map;
72 void reset()
override;
78 void add(
idx_t n,
const float* x)
override;
103 const float *centroid_dis,
104 float *distances,
idx_t *labels,
105 bool store_pairs)
const = 0;
109 float *distances,
idx_t *labels)
const override;
129 long a1,
long a2)
const;
133 size_t get_list_size (
size_t list_no)
const
134 {
return ids[list_no].size(); }
181 virtual void add_core (
idx_t n,
const float * x,
const long *xids,
182 const long *precomputed_idx);
189 const float *centroid_dis,
190 float *distances,
idx_t *labels,
191 bool store_pairs)
const override;
virtual void search_preassigned(idx_t n, const float *x, idx_t k, const idx_t *assign, const float *centroid_dis, float *distances, idx_t *labels, bool store_pairs) const =0
double imbalance_factor() const
1= perfectly balanced, >1: imbalanced
virtual void copy_subset_to(IndexIVF &other, int subset_type, long a1, long a2) const
size_t nprobe
number of probes at query time
void reconstruct(idx_t key, float *recons) const override
void assign(idx_t n, const float *x, idx_t *labels, idx_t k=1)
bool quantizer_trains_alone
just pass over the trainset to quantizer
void range_search(idx_t n, const float *x, float radius, RangeSearchResult *result) const override
virtual void train_residual(idx_t n, const float *x)
std::vector< std::vector< long > > ids
Inverted lists for indexes.
Index * quantizer
quantizer that maps vectors to inverted lists
void train(idx_t n, const float *x) override
Trains the quantizer and calls train_residual to train sub-quantizers.
ClusteringParameters cp
to override default clustering params
void add_with_ids(idx_t n, const float *x, const long *xids) override
implemented for all IndexIVF* classes
bool own_fields
whether object owns the quantizer
long idx_t
all indices are this type
void reset() override
removes all elements from the database.
void update_vectors(int nv, idx_t *idx, const float *v)
void make_direct_map(bool new_maintain_direct_map=true)
void print_stats() const
display some stats about the inverted lists
size_t nlist
number of possible key values
void add(idx_t n, const float *x) override
Quantizes x and calls add_with_key.
long remove_ids(const IDSelector &sel) override
Dataset manipulation functions.
bool maintain_direct_map
map for direct access to the elements. Enables reconstruct().
virtual void search(idx_t n, const float *x, idx_t k, float *distances, idx_t *labels) const override
void search_preassigned(idx_t n, const float *x, idx_t k, const idx_t *assign, const float *centroid_dis, float *distances, idx_t *labels, bool store_pairs) const override
virtual void merge_from(IndexIVF &other, idx_t add_id)
size_t code_size
code size per vector in bytes
MetricType
Some algorithms support both an inner product vetsion and a L2 search version.
virtual void add_core(idx_t n, const float *x, const long *xids, const long *precomputed_idx)
same as add_with_ids, with precomputed coarse quantizer