mirror of https://github.com/milvus-io/milvus.git
Upgrade to knowhere-v1.2.0 (#18746)
Signed-off-by: yudong.cai <yudong.cai@zilliz.com> Signed-off-by: yudong.cai <yudong.cai@zilliz.com>pull/18769/head
parent
641afae22f
commit
94ffa8a275
|
@ -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<int>(conf, knowhere::meta::SLICE_SIZE, stoi_closure, std::optional{4});
|
||||
|
@ -124,16 +124,16 @@ VecIndexCreator::parse() {
|
|||
template <typename T>
|
||||
void
|
||||
VecIndexCreator::check_parameter(knowhere::Config& conf,
|
||||
const std::string_view& key,
|
||||
const std::string& key,
|
||||
std::function<T(std::string)> fn,
|
||||
std::optional<T> 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<std::string>("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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ class VecIndexCreator : public IndexCreatorBase {
|
|||
template <typename T>
|
||||
void
|
||||
check_parameter(knowhere::Config& conf,
|
||||
const std::string_view& key,
|
||||
const std::string& key,
|
||||
std::function<T(std::string)> fn,
|
||||
std::optional<T> default_v = std::nullopt);
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <string>
|
||||
|
||||
#include "PlanImpl.h"
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
#include <vector>
|
||||
|
||||
#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());
|
||||
}
|
||||
|
|
|
@ -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}" )
|
||||
|
|
Loading…
Reference in New Issue