Struct faiss::InvertedListsIOHook

struct InvertedListsIOHook

Callbacks to handle other types of InvertedList objects.

The callbacks should be registered with add_callback before calling read_index or read_InvertedLists. The callbacks for OnDiskInvertedLists are registrered by default. The invlist type is identified by:

  • the key (a fourcc) at read time

  • the class name (as given by typeid.name) at write time

Subclassed by faiss::BlockInvertedListsIOHook, faiss::OnDiskInvertedListsIOHook

Public Functions

InvertedListsIOHook(const std::string &key, const std::string &classname)
virtual void write(const InvertedLists *ils, IOWriter *f) const = 0

write the index to the IOWriter (including the fourcc)

virtual InvertedLists *read(IOReader *f, int io_flags) const = 0

called when the fourcc matches this class’s fourcc

virtual InvertedLists *read_ArrayInvertedLists(IOReader *f, int io_flags, size_t nlist, size_t code_size, const std::vector<size_t> &sizes) const

read from a ArrayInvertedLists into this invertedlist type. For this to work, the callback has to be enabled and the io_flag has to be set to IO_FLAG_SKIP_IVF_DATA | (16 upper bits of the fourcc)

(default implementation fails)

inline virtual ~InvertedListsIOHook()

Public Members

const std::string key

string version of the fourcc

const std::string classname

typeid.name

Public Static Functions

static void add_callback(InvertedListsIOHook*)
static void print_callbacks()
static InvertedListsIOHook *lookup(int h)
static InvertedListsIOHook *lookup_classname(const std::string &classname)