Skip to content

Commit

Permalink
#2890 Fix wrong index size (#2942)
Browse files Browse the repository at this point in the history
* fix NM index size

Signed-off-by: sahuang <xiaohai.xu@zilliz.com>

* add raw data size of hnsw_nm and nsg_nm

Signed-off-by: cmli <chengming.li@zilliz.com>

Co-authored-by: cmli <chengming.li@zilliz.com>
  • Loading branch information
Xiaohai Xu and cmli committed Jul 21, 2020
1 parent 525257a commit d85b3f9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ IndexHNSW_NM::UpdateIndexSize() {
if (!index_) {
KNOWHERE_THROW_MSG("index not initialize");
}
index_size_ = index_->cal_size();
index_size_ = index_->cal_size() + Dim() * Count() * sizeof(float);
}

} // namespace knowhere
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,11 @@ IVFSQNR_NM::UpdateIndexSize() {
}
auto ivfsq_index = dynamic_cast<faiss::IndexIVFScalarQuantizer*>(index_.get());
auto nb = ivfsq_index->invlists->compute_ntotal();
auto code_size = ivfsq_index->code_size;
auto nlist = ivfsq_index->nlist;
auto d = ivfsq_index->d;
// ivf ids, sq trained vectors and quantizer
index_size_ = nb * sizeof(int64_t) + 2 * d * sizeof(float) + nlist * d * sizeof(float);
// ivf codes, ivf ids, sq trained vectors and quantizer
index_size_ = nb * code_size + nb * sizeof(int64_t) + 2 * d * sizeof(float) + nlist * d * sizeof(float);
}

} // namespace knowhere
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@ IVF_NM::UpdateIndexSize() {
auto ivf_index = dynamic_cast<faiss::IndexIVFFlat*>(index_.get());
auto nb = ivf_index->invlists->compute_ntotal();
auto nlist = ivf_index->nlist;
auto d = ivf_index->d;
// ivf ids and quantizer
index_size_ = nb * sizeof(int64_t) + nlist * d * sizeof(float);
auto code_size = ivf_index->code_size;
// ivf codes, ivf ids and quantizer
index_size_ = nb * code_size + nb * sizeof(int64_t) + nlist * code_size;
}

} // namespace knowhere
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ NSG_NM::UpdateIndexSize() {
if (!index_) {
KNOWHERE_THROW_MSG("index not initialize");
}
index_size_ = index_->GetSize();
index_size_ = index_->GetSize() + Dim() * Count() * sizeof(float);
}

} // namespace knowhere
Expand Down

0 comments on commit d85b3f9

Please sign in to comment.