13 #ifndef FAISS_INDEX_IVF_H
14 #define FAISS_INDEX_IVF_H
21 #include "Clustering.h"
56 std::vector < std::vector<long> >
ids;
60 std::vector <long> direct_map;
70 virtual void reset ()
override;
73 virtual void train (
idx_t n,
const float *x)
override;
76 virtual void add (
idx_t n,
const float *x)
override;
116 std::vector < std::vector<float> >
vecs;
128 const long *precomputed_idx);
137 float *distances,
idx_t *labels)
const override;
140 idx_t n,
const float *x,
float radius,
149 long a1,
long a2)
const;
152 virtual void reset()
override;
158 size_t nx,
const float * x,
164 size_t nx,
const float * x,
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
virtual void reconstruct(idx_t key, float *recons) const override
bool quantizer_trains_alone
just pass over the trainset to quantizer
virtual void set_typename() override
virtual 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
virtual void merge_from_residuals(IndexIVF &other) override
virtual void train_residual(idx_t n, const float *x)
virtual 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
virtual 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
virtual 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
virtual void reset() override
removes all elements from the database.
void make_direct_map()
intialize a direct map
virtual void reset() override
removes all elements from the database.
virtual void merge_from_residuals(IndexIVF &other)=0
void print_stats() const
display some stats about the inverted lists
size_t nlist
number of possible key values
virtual 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
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
virtual void search(idx_t n, const float *x, idx_t k, float *distances, idx_t *labels) const override