16 #include "IndexFlat.h"
18 #include "IndexScalarQuantizer.h"
37 std::vector<float> codebook;
39 std::vector<uint8_t> codes;
44 size_t k=256,
size_t nsq=1);
50 size_t compute_distances(
size_t n,
const idx_t *shortlist,
51 const float *query,
float *distances)
const;
54 void estimate_code(
const float *x, storage_idx_t i, uint8_t *code)
const;
57 void reconstruct(storage_idx_t i,
float *x,
float *tmp)
const;
59 void reconstruct_n(storage_idx_t n0, storage_idx_t ni,
float *x)
const;
91 void add(
idx_t n,
const float *x)
override;
98 float *distances,
idx_t *labels)
const override;
102 void reset ()
override;
104 void shrink_level_0_neighbors(
int size);
113 const storage_idx_t *nearest,
const float *nearest_d,
114 float *distances,
idx_t *labels,
int nprobe = 1,
115 int search_type = 1)
const;
119 int k,
const float *D,
const idx_t *I);
123 int npt,
const storage_idx_t *points,
124 const storage_idx_t *nearests);
127 void reorder_links();
129 void link_singletons();
142 get_distance_computer()
const override;
153 get_distance_computer()
const override;
163 get_distance_computer()
const override;
172 get_distance_computer()
const override;
177 float *distances,
idx_t *labels)
const override;
void train(idx_t n, const float *x) override
Trains the storage if needed.
void search(idx_t n, const float *x, idx_t k, float *distances, idx_t *labels) const override
entry point for search
void get_neighbor_table(storage_idx_t i, float *out) const
get the M+1 -by-d table for neighbor coordinates for vector i
void train(idx_t n, const float *x) override
Trains the storage if needed.
void add(idx_t n, const float *x) override
void reconstruct(storage_idx_t i, float *x, float *tmp) const
called by compute_distances
long idx_t
all indices are this type
void estimate_code(const float *x, storage_idx_t i, uint8_t *code) const
called by add_codes
void add_codes(size_t n, const float *x)
void reset() override
removes all elements from the database.
void init_level_0_from_entry_points(int npt, const storage_idx_t *points, const storage_idx_t *nearests)
alternative graph building
void search(idx_t n, const float *x, idx_t k, float *distances, idx_t *labels) const override
entry point for search
void init_level_0_from_knngraph(int k, const float *D, const idx_t *I)
alternative graph building
void search_level_0(idx_t n, const float *x, idx_t k, const storage_idx_t *nearest, const float *nearest_d, float *distances, idx_t *labels, int nprobe=1, int search_type=1) const
void reconstruct(idx_t key, float *recons) const override
int storage_idx_t
internal storage of vectors (32 bits: this is expensive)