Skip to content

Commit

Permalink
Add row number constraint for building scann index (#185)
Browse files Browse the repository at this point in the history
Signed-off-by: chasingegg <[email protected]>
  • Loading branch information
chasingegg authored Nov 8, 2023
1 parent 25bf8a3 commit 107eb5f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/index/ivf/ivf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,15 @@ IvfIndexNode<T>::Train(const DataSet& dataset, const Config& cfg) {
auto dim = dataset.GetDim();
auto data = dataset.GetTensor();

// faiss scann needs at least 16 rows since nbits=4
constexpr int64_t SCANN_MIN_ROWS = 16;
if constexpr (std::is_same<faiss::IndexScaNN, T>::value) {
if (rows < SCANN_MIN_ROWS) {
LOG_KNOWHERE_ERROR_ << rows << " rows is not enough, scann needs at least 16 rows to build index";
return Status::faiss_inner_error;
}
}

typename QuantizerT<T>::type* qzr = nullptr;
faiss::IndexIVFPQFastScan* base_index = nullptr;
std::unique_ptr<T> index;
Expand Down

0 comments on commit 107eb5f

Please sign in to comment.