Faiss
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
faiss::ThreadedIndex< IndexT > Class Template Reference

#include <ThreadedIndex.h>

Inheritance diagram for faiss::ThreadedIndex< IndexT >:
faiss::IndexReplicasTemplate< IndexT > faiss::IndexShardsTemplate< IndexT >

Public Member Functions

 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 own_fields
 Whether or not we are responsible for deleting our contained indices.
 

Protected Member Functions

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

Static Protected Member Functions

static void waitAndHandleFutures (std::vector< std::future< bool >> &v)
 

Protected Attributes

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>
class faiss::ThreadedIndex< IndexT >

A holder of indices in a collection of threads The interface to this class itself is not thread safe

Definition at line 21 of file ThreadedIndex.h.

Member Function Documentation

template<typename IndexT >
void faiss::ThreadedIndex< IndexT >::addIndex ( IndexT *  index)

override an index that is managed by ourselves. WARNING: once an index is added, it becomes unsafe to touch it from any other thread than that on which is managing it, until we are shut down. Use runOnIndex to perform work on it instead.

Definition at line 49 of file ThreadedIndex-inl.h.

template<typename IndexT >
void faiss::ThreadedIndex< IndexT >::removeIndex ( IndexT *  index)

Remove an index that is managed by ourselves. This will flush all pending work on that index, and then shut down its managing thread, and will remove the index.

Definition at line 88 of file ThreadedIndex-inl.h.

template<typename IndexT >
void faiss::ThreadedIndex< IndexT >::reset ( )
override

faiss::Index API All indices receive the same call

Definition at line 156 of file ThreadedIndex-inl.h.

template<typename IndexT >
void faiss::ThreadedIndex< IndexT >::runOnIndex ( std::function< void(int, IndexT *)>  f)

Run a function on all indices, in the thread that the index is managed in. Function arguments are (index in collection, index pointer)

Definition at line 119 of file ThreadedIndex-inl.h.


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