diff --git a/core/src/index/knowhere/knowhere/adapter/SptagAdapter.cpp b/core/src/index/knowhere/knowhere/adapter/SptagAdapter.cpp index c31e262dd8e0128a0ab20e2dad694cf922150a78..9a12093dc43aab05404fd3999bebaab3249002b5 100644 --- a/core/src/index/knowhere/knowhere/adapter/SptagAdapter.cpp +++ b/core/src/index/knowhere/knowhere/adapter/SptagAdapter.cpp @@ -10,6 +10,7 @@ // or implied. See the License for the specific language governing permissions and limitations under the License. #include "knowhere/adapter/SptagAdapter.h" + #include "VectorAdapter.h" namespace knowhere { @@ -19,7 +20,7 @@ ConvertToMetadataSet(const DatasetPtr& dataset) { auto elems = dataset->Get(meta::ROWS); auto p_data = dataset->Get(meta::IDS); - auto p_offset = (int64_t*)malloc(sizeof(int64_t) * elems); + auto p_offset = (int64_t*)malloc(sizeof(int64_t) * (elems + 1)); for (auto i = 0; i <= elems; ++i) p_offset[i] = i * 8; std::shared_ptr metaset( diff --git a/core/src/index/knowhere/knowhere/common/BinarySet.h b/core/src/index/knowhere/knowhere/common/BinarySet.h index ff6c6626fdd40a81bd08201d2d98ca2daeb686c7..199096a794b28a18e0af69e526c59021e0702898 100644 --- a/core/src/index/knowhere/knowhere/common/BinarySet.h +++ b/core/src/index/knowhere/knowhere/common/BinarySet.h @@ -11,6 +11,8 @@ #pragma once +#include + #include #include #include @@ -28,6 +30,13 @@ struct Binary { }; using BinaryPtr = std::shared_ptr; +inline uint8_t* +CopyBinary(const BinaryPtr& bin) { + uint8_t* newdata = new uint8_t[bin->size]; + memcpy(newdata, bin->data.get(), bin->size); + return newdata; +} + class BinarySet { public: BinaryPtr diff --git a/core/src/index/knowhere/knowhere/index/vector_index/IndexSPTAG.cpp b/core/src/index/knowhere/knowhere/index/vector_index/IndexSPTAG.cpp index 2b9f7a79c2db2f8b54ec93a83bd355ce02973214..5066790967a1ffc3fc8a20028e7338f78a771d07 100644 --- a/core/src/index/knowhere/knowhere/index/vector_index/IndexSPTAG.cpp +++ b/core/src/index/knowhere/knowhere/index/vector_index/IndexSPTAG.cpp @@ -104,7 +104,7 @@ CPUSPTAGRNG::Load(const BinarySet& binary_set) { index_blobs.push_back(SPTAG::ByteArray(deleteid->data.get(), deleteid->size, false)); auto metadata1 = binary_set.GetByName("metadata1"); - index_blobs.push_back(SPTAG::ByteArray(metadata1->data.get(), metadata1->size, false)); + index_blobs.push_back(SPTAG::ByteArray(CopyBinary(metadata1), metadata1->size, true)); auto metadata2 = binary_set.GetByName("metadata2"); index_blobs.push_back(SPTAG::ByteArray(metadata2->data.get(), metadata2->size, false)); diff --git a/core/src/scheduler/job/BuildIndexJob.cpp b/core/src/scheduler/job/BuildIndexJob.cpp index 0da63214be29a98edc5e0a7709732a95622e3edc..fd843059526cde241f1cb644fcdaf2e4b5de804a 100644 --- a/core/src/scheduler/job/BuildIndexJob.cpp +++ b/core/src/scheduler/job/BuildIndexJob.cpp @@ -39,9 +39,10 @@ BuildIndexJob::AddToIndexFiles(const engine::meta::TableFileSchemaPtr& to_index_ << ", location: " << to_index_file->location_; to_index_files_[to_index_file->id_] = to_index_file; + return true; } -Status& +void BuildIndexJob::WaitBuildIndexFinish() { std::unique_lock lock(mutex_); cv_.wait(lock, [this] { return to_index_files_.empty(); }); diff --git a/core/src/scheduler/job/BuildIndexJob.h b/core/src/scheduler/job/BuildIndexJob.h index c057c0fb4897cfae6f084aa7082762cb0cd9c028..09c8330da7cd28d0b3e416bc5bea84d07f9b4e26 100644 --- a/core/src/scheduler/job/BuildIndexJob.h +++ b/core/src/scheduler/job/BuildIndexJob.h @@ -44,7 +44,7 @@ class BuildIndexJob : public Job, public server::CacheConfigHandler { bool AddToIndexFiles(const TableFileSchemaPtr& to_index_file); - Status& + void WaitBuildIndexFinish(); void