12 #ifndef FAISS_INDEX_IVF_H
13 #define FAISS_INDEX_IVF_H
20 #include "Clustering.h"
48 void train_q1 (
size_t n,
const float *x,
bool verbose,
81 std::vector < std::vector<long> >
ids;
84 std::vector < std::vector<uint8_t> > codes;
88 std::vector <long> direct_map;
98 void reset()
override;
104 void add(
idx_t n,
const float* x)
override;
129 const float *centroid_dis,
130 float *distances,
idx_t *labels,
131 bool store_pairs)
const = 0;
135 float *distances,
idx_t *labels)
const override;
160 float *distances,
idx_t *labels,
161 float *recons)
const override;
171 float* recons)
const;
191 long a1,
long a2)
const;
195 size_t get_list_size (
size_t list_no)
const
196 {
return ids[list_no].size(); }
242 virtual void add_core (
idx_t n,
const float * x,
const long *xids,
243 const long *precomputed_idx);
250 const float *centroid_dis,
251 float *distances,
idx_t *labels,
252 bool store_pairs)
const override;
271 float* recons)
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
void search_and_reconstruct(idx_t n, const float *x, idx_t k, float *distances, idx_t *labels, float *recons) const override
virtual void copy_subset_to(IndexIVF &other, int subset_type, long a1, long a2) const
virtual void reconstruct_from_offset(long list_no, long offset, float *recons) const
size_t nprobe
number of probes at query time
void assign(idx_t n, const float *x, idx_t *labels, idx_t k=1)
void range_search(idx_t n, const float *x, float radius, RangeSearchResult *result) const override
void reconstruct(idx_t key, float *recons) const override
virtual void train_residual(idx_t n, const float *x)
std::vector< std::vector< long > > ids
Inverted lists for indexes.
void train(idx_t n, const float *x) override
Trains the quantizer and calls train_residual to train sub-quantizers.
void reconstruct_n(idx_t i0, idx_t ni, float *recons) const override
void add_with_ids(idx_t n, const float *x, const long *xids) override
implemented for all IndexIVF* classes
char quantizer_trains_alone
long idx_t
all indices are this type
ClusteringParameters cp
to override default clustering params
void reconstruct_from_offset(long list_no, long offset, float *recons) const override
void reset() override
removes all elements from the database.
void update_vectors(int nv, idx_t *idx, const float *v)
Index * clustering_index
to override index used during clustering
void train_q1(size_t n, const float *x, bool verbose, MetricType metric_type)
Trains the quantizer and calls train_residual to train sub-quantizers.
void make_direct_map(bool new_maintain_direct_map=true)
void print_stats() const
display some stats about the inverted lists
void add(idx_t n, const float *x) override
Quantizes x and calls add_with_key.
Index * quantizer
quantizer that maps vectors to inverted lists
long remove_ids(const IDSelector &sel) override
Dataset manipulation functions.
size_t max_codes
max nb of codes to visit to do a query
bool maintain_direct_map
map for direct access to the elements. Enables reconstruct().
bool own_fields
whether object owns the quantizer
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 nlist
number of possible key values
size_t code_size
code size per vector in bytes
MetricType
Some algorithms support both an inner product version 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