diff --git a/internal/core/src/common/Schema.cpp b/internal/core/src/common/Schema.cpp index a6e7c892ef220c0bd2dc0fa6a8eec6cd30499ac2..d5da651db1708c7aa2798be7811a040a625596f3 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 cadf62e8cb73750a34459b3407b0a486e4f14e7e..8975b201bb873fd8f39ac3b2f50c0e2e2fa0b774 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 1e1c2f58a0fd353038d20aa250bb00e1de385e0f..4b97237c8d59828ec32a3614f5867f1500505dca 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"