Faiss

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
Public Types | Public Member Functions | Public Attributes | List of all members
faiss::IndexIVFPQCompact Struct Reference

`#include <IndexIVFPQ.h>`

Inheritance diagram for faiss::IndexIVFPQCompact:

## Public Types
enum | Alloc_type_t { Alloc_type_none, Alloc_type_new, Alloc_type_mmap }
| how were the compact tables allocated? More...
Public Types inherited from faiss::Index
typedef long | idx_t
| all indices are this type

## Public Member Functions
| IndexIVFPQCompact (const IndexIVFPQ &other)
virtual void | search_knn_with_key (size_t nx, const float *qx, const long *keys, const float *coarse_dis, float_maxheap_array_t *res, bool store_pairs=false) const override
virtual void | add (idx_t, const float *) override
| the three following functions will fail at runtime
virtual void | reset () override
| removes all elements from the database.
virtual void | train (idx_t, const float *) override
| Trains the quantizer and calls train_residual to train sub-quantizers.
Public Member Functions inherited from faiss::IndexIVFPQ
| IndexIVFPQ (Index *quantizer, size_t d, size_t nlist, size_t M, size_t nbits_per_idx)
virtual void | set_typename () override
virtual void | add_with_ids (idx_t n, const float *x, const long *xids=nullptr) override
void | add_core_o (idx_t n, const float *x, const long *xids, float *residuals_2, const long *precomputed_idx=nullptr)
virtual void | search (idx_t n, const float *x, idx_t k, float *distances, idx_t *labels) const override
virtual long | remove_ids (const IDSelector &sel) override
virtual void | train_residual (idx_t n, const float *x) override
| trains the product quantizer
void | train_residual_o (idx_t n, const float *x, float *residuals_2)
| same as train_residual, also output 2nd level residuals
virtual void | reconstruct_n (idx_t i0, idx_t ni, float *recons) const override
virtual void | reconstruct (idx_t key, float *recons) const override
size_t | find_duplicates (idx_t *ids, size_t *lims) const
void | encode (long key, const float *x, uint8_t *code) const
void | encode_multiple (size_t n, const long *keys, const float *x, uint8_t *codes) const
| same as encode, for multiple points at once
void | precompute_table ()
| build precomputed table More...
virtual void | merge_from_residuals (IndexIVF &other) override
| used to implement merging
void | copy_subset_to (IndexIVFPQ &other, int subset_type, long a1, long a2) const
Public Member Functions inherited from faiss::IndexIVF
| IndexIVF (Index *quantizer, size_t d, size_t nlist, MetricType metric=METRIC_INNER_PRODUCT)
virtual void | merge_from (IndexIVF &other, idx_t add_id)
void | make_direct_map ()
| intialize a direct map
double | imbalance_factor () const
| 1= perfectly balanced, >1: imbalanced
void | print_stats () const
| display some stats about the inverted lists
Public Member Functions inherited from faiss::Index
| Index (idx_t d=0, MetricType metric=METRIC_INNER_PRODUCT)
virtual void | range_search (idx_t n, const float *x, float radius, RangeSearchResult *result) const
void | assign (idx_t n, const float *x, idx_t *labels, idx_t k=1)
void | compute_residual (const float *x, float *residual, idx_t key) const
void | display () const
virtual std::string | get_typename () const

## Public Attributes
Alloc_type_t | alloc_type
uint32_t * | limits
| size nlist + 1
uint32_t * | compact_ids
| size ntotal
uint8_t * | compact_codes
| size ntotal * code_size
char * | mmap_buffer
long | mmap_length
Public Attributes inherited from faiss::IndexIVFPQ
bool | by_residual
| Encode residual or plain vector?
int | use_precomputed_table
| if by_residual, build precompute tables
size_t | code_size
| code size per vector in bytes
ProductQuantizer | pq
| produces the codes
bool | do_polysemous_training
| reorder PQ centroids after training?
PolysemousTraining * | polysemous_training
| if NULL, use default
size_t | scan_table_threshold
| use table computation or on-the-fly?
size_t | max_codes
| max nb of codes to visit to do a query
int | polysemous_ht
| Hamming thresh for polysemous filtering.
std::vector< std::vector < uint8_t > > | codes
std::vector< float > | precomputed_table
Public Attributes inherited from faiss::IndexIVF
size_t | nlist
| number of possible key values
size_t | nprobe
| number of probes at query time
Index * | quantizer
| quantizer that maps vectors to inverted lists
bool | quantizer_trains_alone
| just pass over the trainset to quantizer
bool | own_fields
| whether object owns the quantizer
ClusteringParameters | cp
| to override default clustering params
std::vector< std::vector< long > > | ids
| Inverted lists for indexes.
bool | maintain_direct_map
| map for direct access to the elements. Enables reconstruct().
std::vector< long > | direct_map
Public Attributes inherited from faiss::Index
std::string | index_typename
int | d
| vector dimension
idx_t | ntotal
| total nb of indexed vectors
bool | verbose
| verbosity level
bool | is_trained
| set if the Index does not require training, or if training is done already
MetricType | metric_type
| type of metric this index uses for search

## Detailed Description

Index with 32-bit ids and flat tables. Must be constructed from an exisiting IndexIVFPQ. Cannot be copy-constructed/assigned. The actual data is stored in the compact_* tables, the ids and codes tables are not used.

Definition at line 235 of file IndexIVFPQ.h.

## Member Enumeration Documentation

enum faiss::IndexIVFPQCompact::Alloc_type_t

how were the compact tables allocated?

Enumerator
Alloc_type_none | alloc from outside
Alloc_type_new | was allocated with new
Alloc_type_mmap | was mmapped

Definition at line 240 of file IndexIVFPQ.h.

## Member Function Documentation

void faiss::IndexIVFPQCompact::search_knn_with_key | ( | size_t | nx,
|  | const float * | qx,
|  | const long * | keys,
|  | const float * | coarse_dis,
|  | float_maxheap_array_t * | res,
|  | bool | store_pairs = `false`
| ) |  | const
| override virtual

search a set of vectors, that are pre-quantized by the IVF quantizer. Fill in the corresponding heaps with the query results.

Parameters

  nx | nb of vectors to query
  qx | query vectors, size nx * d
  keys | coarse quantization indices, size nx * nprobe
  coarse_dis | distances to coarse centroids, size nx * nprobe
  res | heaps for all the results, gives the nprobe
  store_pairs | store inv list index + inv list offset instead in upper/lower 32 bit of result, instead of ids (used for reranking).

Reimplemented from faiss::IndexIVFPQ.

Definition at line 1473 of file IndexIVFPQ.cpp.

The documentation for this struct was generated from the following files:

- /data/users/matthijs/github_faiss/faiss/IndexIVFPQ.h
- /data/users/matthijs/github_faiss/faiss/IndexIVFPQ.cpp