diff --git a/internal/core/src/indexbuilder/VecIndexCreator.cpp b/internal/core/src/indexbuilder/VecIndexCreator.cpp index 81bd8a7e4cf6776ce79cd7e57a0ea6903c8d64a7..96fee27b5439cb416f4b71f0a17e224a1d81d756 100644 --- a/internal/core/src/indexbuilder/VecIndexCreator.cpp +++ b/internal/core/src/indexbuilder/VecIndexCreator.cpp @@ -58,8 +58,8 @@ VecIndexCreator::parse_impl(const std::string& serialized_params_str, knowhere:: conf[key] = value; } - auto stoi_closure = [](const std::string_view& s) -> int { return std::stoi(std::string(s)); }; - auto stof_closure = [](const std::string_view& s) -> float { return std::stof(std::string(s)); }; + auto stoi_closure = [](const std::string& s) -> int { return std::stoi(s); }; + auto stof_closure = [](const std::string& s) -> float { return std::stof(s); }; /***************************** meta *******************************/ check_parameter(conf, knowhere::meta::SLICE_SIZE, stoi_closure, std::optional{4}); @@ -124,16 +124,16 @@ VecIndexCreator::parse() { template void VecIndexCreator::check_parameter(knowhere::Config& conf, - const std::string_view& key, + const std::string& key, std::function fn, std::optional default_v) { if (!conf.contains(key)) { if (default_v.has_value()) { - conf[std::string(key)] = default_v.value(); + conf[key] = default_v.value(); } } else { - auto value = conf[std::string(key)]; - conf[std::string(key)] = fn(value); + auto value = conf[key]; + conf[key] = fn(value); } } @@ -264,7 +264,7 @@ VecIndexCreator::get_index_type() { // knowhere bug here // the index_type of all ivf-based index will change to ivf flat after loaded auto type = get_config_by_name("index_type"); - return type.has_value() ? type.value() : std::string(knowhere::IndexEnum::INDEX_FAISS_IVFPQ); + return type.has_value() ? type.value() : knowhere::IndexEnum::INDEX_FAISS_IVFPQ; } std::string @@ -275,9 +275,9 @@ VecIndexCreator::get_metric_type() { } else { auto index_type = get_index_type(); if (is_in_bin_list(index_type)) { - return std::string(knowhere::metric::JACCARD); + return knowhere::metric::JACCARD; } else { - return std::string(knowhere::metric::L2); + return knowhere::metric::L2; } } } diff --git a/internal/core/src/indexbuilder/VecIndexCreator.h b/internal/core/src/indexbuilder/VecIndexCreator.h index 0eeb7ab1fda22769418cf74ef5e768435735e59b..d1a6ce50316f39a4df8322455b717e3ab8efe2d4 100644 --- a/internal/core/src/indexbuilder/VecIndexCreator.h +++ b/internal/core/src/indexbuilder/VecIndexCreator.h @@ -85,7 +85,7 @@ class VecIndexCreator : public IndexCreatorBase { template void check_parameter(knowhere::Config& conf, - const std::string_view& key, + const std::string& key, std::function fn, std::optional default_v = std::nullopt); diff --git a/internal/core/src/query/Plan.h b/internal/core/src/query/Plan.h index c29bf1c5c2a0e2c7455463934a5b5a7ff18a1c36..a8f623cbaa6af0662d005df352ca65b9a93e48e8 100644 --- a/internal/core/src/query/Plan.h +++ b/internal/core/src/query/Plan.h @@ -12,7 +12,6 @@ #pragma once #include -#include #include #include "PlanImpl.h" diff --git a/internal/core/src/query/SearchBruteForce.cpp b/internal/core/src/query/SearchBruteForce.cpp index cb53937c85ea457496e083ff5ca043616877331e..374d02594b43ef913a850cdddfcf6ac11bcdc98d 100644 --- a/internal/core/src/query/SearchBruteForce.cpp +++ b/internal/core/src/query/SearchBruteForce.cpp @@ -13,7 +13,9 @@ #include #include "SearchBruteForce.h" +#include "SubSearchResult.h" #include "knowhere/archive/BruteForce.h" +#include "knowhere/index/vector_index/adapter/VectorAdapter.h" namespace milvus::query { @@ -24,9 +26,24 @@ BruteForceSearch(const dataset::SearchDataset& dataset, const BitsetView& bitset) { SubSearchResult sub_result(dataset.num_queries, dataset.topk, dataset.metric_type, dataset.round_decimal); try { - knowhere::BruteForceSearch(dataset.metric_type, chunk_data_raw, dataset.query_data, dataset.dim, chunk_rows, - dataset.num_queries, dataset.topk, sub_result.get_seg_offsets(), - sub_result.get_distances(), bitset); + auto nq = dataset.num_queries; + auto dim = dataset.dim; + auto topk = dataset.topk; + + auto base_dataset = knowhere::GenDataset(chunk_rows, dim, chunk_data_raw); + auto query_dataset = knowhere::GenDataset(nq, dim, dataset.query_data); + auto config = knowhere::Config{ + {knowhere::meta::METRIC_TYPE, dataset.metric_type}, + {knowhere::meta::DIM, dim}, + {knowhere::meta::TOPK, topk}, + }; + auto result = knowhere::BruteForce::Search(base_dataset, query_dataset, config, bitset); + + sub_result.mutable_seg_offsets().resize(nq * topk); + sub_result.mutable_distances().resize(nq * topk); + + std::copy_n(knowhere::GetDatasetIDs(result), nq * topk, sub_result.get_seg_offsets()); + std::copy_n(knowhere::GetDatasetDistance(result), nq * topk, sub_result.get_distances()); } catch (std::exception& e) { PanicInfo(e.what()); } diff --git a/internal/core/thirdparty/knowhere/CMakeLists.txt b/internal/core/thirdparty/knowhere/CMakeLists.txt index 8f49df5ccc6c343f2e28918f45106450e6957324..d8b008f1b7dad5225d4fb7e79b5f2ba7904c585f 100644 --- a/internal/core/thirdparty/knowhere/CMakeLists.txt +++ b/internal/core/thirdparty/knowhere/CMakeLists.txt @@ -11,8 +11,8 @@ # or implied. See the License for the specific language governing permissions and limitations under the License. #------------------------------------------------------------------------------- -set( KNOWHERE_VERSION v1.1.14 ) -set( KNOWHERE_SOURCE_MD5 "de9303c3f667662aa92f3676a1f6ef96") +set( KNOWHERE_VERSION v1.2.0 ) +set( KNOWHERE_SOURCE_MD5 "acc955a3b90c03f0afd0ff855e594777") if ( DEFINED ENV{MILVUS_KNOWHERE_URL} ) set( KNOWHERE_SOURCE_URL "$ENV{MILVUS_KNOWHERE_URL}" )