未验证 提交 d85b3f95 编写于 作者: X Xiaohai Xu 提交者: GitHub

#2890 Fix wrong index size (#2942)

* fix NM index size
Signed-off-by: Nsahuang <xiaohai.xu@zilliz.com>

* add raw data size of hnsw_nm and nsg_nm
Signed-off-by: Ncmli <chengming.li@zilliz.com>
Co-authored-by: Ncmli <chengming.li@zilliz.com>
上级 525257a2
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册