From 2a5a20ea7cfda635db3bc6c426db6c23864e78d9 Mon Sep 17 00:00:00 2001 From: shenyushi Date: Wed, 25 Dec 2024 10:01:53 +0800 Subject: [PATCH] Fix unit test. --- src/storage/knn_index/knn_hnsw/data_store/data_store_util.cppm | 2 ++ src/storage/knn_index/knn_hnsw/data_store/lvq_vec_store.cppm | 2 +- src/unit_test/storage/knnindex/knn_hnsw/test_hnsw.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/storage/knn_index/knn_hnsw/data_store/data_store_util.cppm b/src/storage/knn_index/knn_hnsw/data_store/data_store_util.cppm index c6ee0d7867..e53b61525e 100644 --- a/src/storage/knn_index/knn_hnsw/data_store/data_store_util.cppm +++ b/src/storage/knn_index/knn_hnsw/data_store/data_store_util.cppm @@ -31,6 +31,8 @@ public: T *get() const { return ptr_.get(); } + UniquePtr exchange(UniquePtr ptr) { return std::exchange(ptr_, std::move(ptr)); } + private: UniquePtr ptr_; }; diff --git a/src/storage/knn_index/knn_hnsw/data_store/lvq_vec_store.cppm b/src/storage/knn_index/knn_hnsw/data_store/lvq_vec_store.cppm index 4a090f2682..d820768cd0 100644 --- a/src/storage/knn_index/knn_hnsw/data_store/lvq_vec_store.cppm +++ b/src/storage/knn_index/knn_hnsw/data_store/lvq_vec_store.cppm @@ -258,7 +258,7 @@ public: for (SizeT i = 0; i < this->dim_; ++i) { new_mean[i] /= cur_vec_num; } - this->mean_ = std::move(new_mean); + new_mean = this->mean_.exchange(std::move(new_mean)); // for (auto [inner, size] : inners) { for (SizeT i = 0; i < size; ++i) { diff --git a/src/unit_test/storage/knnindex/knn_hnsw/test_hnsw.cpp b/src/unit_test/storage/knnindex/knn_hnsw/test_hnsw.cpp index 7ce3a30531..4ef86209fc 100644 --- a/src/unit_test/storage/knnindex/knn_hnsw/test_hnsw.cpp +++ b/src/unit_test/storage/knnindex/knn_hnsw/test_hnsw.cpp @@ -113,7 +113,7 @@ class HnswAlgTest : public BaseTest { int dim = 16; int M = 8; int ef_construction = 200; - int chunk_size = 16; + int chunk_size = 128; int max_chunk_n = 10; int element_size = max_chunk_n * chunk_size;