12 #ifndef FAISS_INDEX_IVF_H
13 #define FAISS_INDEX_IVF_H
20 #include "Clustering.h"
55 std::vector < std::vector<long> >
ids;
59 std::vector <long> direct_map;
69 void reset()
override;
75 void add(
idx_t n,
const float* x)
override;
91 size_t get_list_size (
size_t list_no)
const
92 {
return ids[list_no].size(); }
135 std::vector < std::vector<float> >
vecs;
142 virtual void add_core (
idx_t n,
const float * x,
const long *xids,
143 const long *precomputed_idx);
153 idx_t* labels)
const override;
158 float *distances,
idx_t *labels)
const;
172 long a1,
long a2)
const;
174 void reset()
override;
180 size_t nx,
const float * x,
186 size_t nx,
const float * x,
223 const long* precomputed_idx)
override;
230 idx_t* labels)
const override;
void search_preassigned(idx_t n, const float *x, idx_t k, const idx_t *assign, float *distances, idx_t *labels) const
perform search, without computing the assignment to the quantizer
void search_knn_L2sqr(size_t nx, const float *x, const long *keys, float_maxheap_array_t *res) const
Implementation of the search for the L2 metric.
double imbalance_factor() const
1= perfectly balanced, >1: imbalanced
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
void copy_subset_to(IndexIVFFlat &other, int subset_type, long a1, long a2) const
void merge_from_residuals(IndexIVF &other) override
virtual void train_residual(idx_t n, const float *x)
long remove_ids(const IDSelector &sel) override
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 reset() override
removes all elements from the database.
void update_vectors(int nv, idx_t *idx, const float *v)
void search(idx_t n, const float *x, idx_t k, float *distances, idx_t *labels) const override
std::vector< std::vector< float > > part_norms
norm of remainder (dimensions fsize:d)
size_t fsize
nb of dimensions of pre-filter
virtual void merge_from_residuals(IndexIVF &other)=0
void make_direct_map(bool new_maintain_direct_map=true)
void print_stats() const
display some stats about the inverted lists
void add_core(idx_t n, const float *x, const long *xids, const long *precomputed_idx) override
same as add_with_ids, with precomputed coarse quantizer
size_t nlist
number of possible key values
void add(idx_t n, const float *x) override
Quantizes x and calls add_with_key.
void search_knn_inner_product(size_t nx, const float *x, const long *keys, float_minheap_array_t *res) const
Implementation of the search for the inner product metric.
bool maintain_direct_map
map for direct access to the elements. Enables reconstruct().
virtual void merge_from(IndexIVF &other, idx_t add_id)
MetricType
Some algorithms support both an inner product vetsion and a L2 search version.
std::vector< std::vector< float > > vecs
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
void search(idx_t n, const float *x, idx_t k, float *distances, idx_t *labels) const override