Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2890 Fix wrong index size #2942

Merged
merged 2 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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