All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
faiss::IndexShardsTemplate< IndexT > Struct Template Reference

`#include <IndexShards.h>`

Inheritance diagram for faiss::IndexShardsTemplate< IndexT >:

## Public Types

using | idx_t = typename IndexT::idx_t
using | component_t = typename IndexT::component_t
using | distance_t = typename IndexT::distance_t

## Public Member Functions

| IndexShardsTemplate (bool threaded=false, bool successive_ids=true)
| IndexShardsTemplate (idx_t d, bool threaded=false, bool successive_ids=true)
| IndexShardsTemplate (int d, bool threaded=false, bool successive_ids=true)
void | add_shard (IndexT *index)
| Alias for addIndex()
void | remove_shard (IndexT *index)
| Alias for removeIndex()
void | add (idx_t n, const component_t *x) override
| supported only for sub-indices that implement add_with_ids
void | add_with_ids (idx_t n, const component_t *x, const idx_t *xids) override
void | search (idx_t n, const component_t *x, idx_t k, distance_t *distances, idx_t *labels) const override
void | train (idx_t n, const component_t *x) override
void | sync_with_shard_indexes ()
Public Member Functions inherited from faiss::ThreadedIndex< IndexT >
| ThreadedIndex (bool threaded)
| ThreadedIndex (int d, bool threaded)
void | addIndex (IndexT *index)
void | removeIndex (IndexT *index)
void | runOnIndex (std::function< void(int, IndexT *)> f)
void | runOnIndex (std::function< void(int, const IndexT *)> f) const
void | reset () override
int | count () const
| Returns the number of sub-indices.
IndexT * | at (int i)
| Returns the i-th sub-index.
const IndexT * | at (int i) const
| Returns the i-th sub-index (const version)

## Public Attributes

bool | successive_ids
Public Attributes inherited from faiss::ThreadedIndex< IndexT >
bool | own_fields
| Whether or not we are responsible for deleting our contained indices.

## Protected Member Functions

void | onAfterAddIndex (IndexT *index) override
| Called just after an index is added.
void | onAfterRemoveIndex (IndexT *index) override
| Called just after an index is removed.

## Additional Inherited Members

Static Protected Member Functions inherited from faiss::ThreadedIndex< IndexT >
static void | waitAndHandleFutures (std::vector< std::future< bool >> &v)
Protected Attributes inherited from faiss::ThreadedIndex< IndexT >
std::vector< std::pair< IndexT *, std::unique_ptr < WorkerThread > > > | indices_
| Collection of Index instances, with their managing worker thread if any.
bool | isThreaded_
| Is this index multi-threaded?

## Detailed Description

### template<typename IndexT>
struct faiss::IndexShardsTemplate< IndexT >

Index that concatenates the results from several sub-indexes

Definition at line 20 of file IndexShards.h.

## Constructor & Destructor Documentation

template<typename IndexT >

faiss::IndexShardsTemplate< IndexT >::IndexShardsTemplate | ( | bool | threaded = `false`,
|  | bool | successive_ids = `true`
| ) |  |

explicit

The dimension that all sub-indices must share will be the dimension of the first sub-index added

Parameters

  threaded | do we use one thread per sub_index or do queries sequentially?
  successive_ids | should we shift the returned ids by the size of each sub-index or return them as they are?

Definition at line 126 of file IndexShards.cpp.

template<typename IndexT >

faiss::IndexShardsTemplate< IndexT >::IndexShardsTemplate | ( | idx_t | d,
|  | bool | threaded = `false`,
|  | bool | successive_ids = `true`
| ) |  |

explicit

Parameters

  threaded | do we use one thread per sub_index or do queries sequentially?
  successive_ids | should we shift the returned ids by the size of each sub-index or return them as they are?

Definition at line 110 of file IndexShards.cpp.

template<typename IndexT >

faiss::IndexShardsTemplate< IndexT >::IndexShardsTemplate | ( | int | d,
|  | bool | threaded = `false`,
|  | bool | successive_ids = `true`
| ) |  |

explicit

int version due to the implicit bool conversion ambiguity of int as dimension

Definition at line 118 of file IndexShards.cpp.

## Member Function Documentation

template<typename IndexT >

void faiss::IndexShardsTemplate< IndexT >::add_with_ids | ( | idx_t | n,
|  | const component_t * | x,
|  | const idx_t * | xids
| ) |  |

override

Cases (successive_ids, xids):

- true, non-NULL ERROR: it makes no sense to pass in ids and request them to be shifted
- true, NULL OK, but should be called only once (calls add() on sub-indexes).
- false, non-NULL OK: will call add_with_ids with passed in xids distributed evenly over shards
- false, NULL OK: will call add_with_ids on each sub-index, starting at ntotal

Definition at line 198 of file IndexShards.cpp.

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

- /data/users/hoss/faiss/IndexShards.h
- /data/users/hoss/faiss/IndexShards.cpp