Skip to content

Commit

Permalink
fix segment fault when indexing BINARYIVF (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maslino authored Apr 1, 2021
1 parent 2739f85 commit 71f83d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions index/impl/gamma_index_binary_ivf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,13 @@ int GammaIndexBinaryIVF::Indexing() {
if (lens.size() == 1) {
train_vec = headers.Get(0);
} else {
int raw_d = d;
int raw_d = raw_vec->MetaInfo()->Dimension();
train_vec = new uint8_t[raw_d * num];
del_vec.set(train_vec);
size_t offset = 0;
for (size_t i = 0; i < headers.Size(); ++i) {
memcpy((void *)(train_vec + offset), (void *)headers.Get(i),
sizeof(float) * raw_d * lens[i]);
sizeof(char) * raw_d * lens[i]);
offset += raw_d * lens[i];
}
}
Expand Down
4 changes: 2 additions & 2 deletions vector/vector_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,16 @@ int VectorManager::AddRTVecsToIndex() {
} else {
int raw_d = raw_vec->MetaInfo()->Dimension();
if (raw_vec->MetaInfo()->DataType() == VectorValueType::BINARY) {
raw_d /= 8;
add_vec = new uint8_t[raw_d * count_per_index];
} else {
add_vec = new uint8_t[raw_d * count_per_index * sizeof(float)];
}
del_vec.set(add_vec);
size_t offset = 0;
size_t element_size = raw_vec->MetaInfo()->DataType() == VectorValueType::BINARY ? sizeof(char) : sizeof(float);
for (size_t i = 0; i < vector_head.Size(); ++i) {
memcpy((void *)(add_vec + offset), (void *)vector_head.Get(i),
sizeof(float) * raw_d * lens[i]);
element_size * raw_d * lens[i]);

if (raw_vec->MetaInfo()->DataType() == VectorValueType::BINARY) {
offset += raw_d * lens[i];
Expand Down

0 comments on commit 71f83d4

Please sign in to comment.