Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagecpp
  virtual DatasetPtr
  QueryByRange(const DatasetPtr& dataset, const Config& config, const faiss::BitsetView bitset);


There is one proposal that not to add new interface QueryByRange(), but reusing interface Query() for range search. Considering the implementation in Knowhere, we don't accept this proposal, because not all types of index support range search.

By now, Knowhere can support 13 types of index, but only 8 of them can support range search (the cell filled with BLUE):

BinaryIDMAPBinaryIVF


IDMAPIVF_FLATIVF_FLAT_NMIVF_SQIVF_PQ
HNSWANNOY


RHNSW_FLATRHNSW_IVFRHNSW_SQRHNSW_PQ

If add new interface QueryByRange(),  we can add following code into "VecIndex.h". If QueryByRange() is called for an index type which does not support range search, a knowhere exception will be thrown out.

Code Block
languagecpp
virtual DatasetPtr
QueryByRange(const DatasetPtr& dataset, const Config& config, const faiss::BitsetView bitset) {
    KNOWHERE_THROW_MSG("QueryByRange not supported yet");
}

I we reuse interface Query() for range search, then the implementation of Query() for all index types will be change like this:

Code Block
languagecpp
virtual DatasetPtr
Query(const DatasetPtr& dataset, const Config& config, const faiss::BitsetView bitset) {
    if (radius exist in config) {
        // do range search
    } else {
        // do query
    }
}


Design Details(required)

Describe the new thing you want to do in appropriate detail. This may be fairly extensive and have large subsections of its own. Or it may be a few sentences. Use judgment based on the scope of the change.

...