From 1446cd5453185c6ada40e461c001bdd3207f7dab Mon Sep 17 00:00:00 2001 From: FluorineDog Date: Wed, 7 Apr 2021 10:39:35 +0800 Subject: [PATCH] Fix flat unsupported bug Signed-off-by: FluorineDog --- internal/core/src/common/Schema.cpp | 16 ++++++++-------- internal/core/src/common/Schema.h | 6 +++++- internal/core/src/common/Types.cpp | 3 --- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/internal/core/src/common/Schema.cpp b/internal/core/src/common/Schema.cpp index a6e7c892ef..d5da651db1 100644 --- a/internal/core/src/common/Schema.cpp +++ b/internal/core/src/common/Schema.cpp @@ -11,8 +11,10 @@ #include "common/Schema.h" #include +#include #include #include "common/SystemProperty.h" +#include namespace milvus { @@ -57,17 +59,15 @@ Schema::ParseFrom(const milvus::proto::schema::CollectionSchema& schema_proto) { if (datatype_is_vector(data_type)) { auto type_map = RepeatedKeyValToMap(child.type_params()); auto index_map = RepeatedKeyValToMap(child.index_params()); - if (!index_map.count("metric_type")) { - auto default_metric_type = - data_type == DataType::VECTOR_FLOAT ? MetricType::METRIC_L2 : MetricType::METRIC_Jaccard; - index_map["metric_type"] = MetricTypeToName(default_metric_type); - } AssertInfo(type_map.count("dim"), "dim not found"); auto dim = boost::lexical_cast(type_map.at("dim")); - AssertInfo(index_map.count("metric_type"), "index not found"); - auto metric_type = GetMetricType(index_map.at("metric_type")); - schema->AddField(name, field_id, data_type, dim, metric_type); + if (!index_map.count("metric_type")) { + schema->AddField(name, field_id, data_type, dim, std::nullopt); + } else { + auto metric_type = GetMetricType(index_map.at("metric_type")); + schema->AddField(name, field_id, data_type, dim, metric_type); + } } else { schema->AddField(name, field_id, data_type); } diff --git a/internal/core/src/common/Schema.h b/internal/core/src/common/Schema.h index cadf62e8cb..8975b201bb 100644 --- a/internal/core/src/common/Schema.h +++ b/internal/core/src/common/Schema.h @@ -52,7 +52,11 @@ class Schema { // vector type void - AddField(const FieldName& name, const FieldId id, DataType data_type, int64_t dim, MetricType metric_type) { + AddField(const FieldName& name, + const FieldId id, + DataType data_type, + int64_t dim, + std::optional metric_type) { auto field_meta = FieldMeta(name, id, data_type, dim, metric_type); this->AddField(std::move(field_meta)); } diff --git a/internal/core/src/common/Types.cpp b/internal/core/src/common/Types.cpp index 1e1c2f58a0..4b97237c8d 100644 --- a/internal/core/src/common/Types.cpp +++ b/internal/core/src/common/Types.cpp @@ -9,9 +9,6 @@ // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express // or implied. See the License for the specific language governing permissions and limitations under the License -// -// Created by mike on 12/3/20. -// #include "common/Types.h" #include #include "exceptions/EasyAssert.h"