提交 1446cd54 编写于 作者: F FluorineDog 提交者: yefu.chen

Fix flat unsupported bug

Signed-off-by: NFluorineDog <guilin.gou@zilliz.com>
上级 bfb7ca0d
......@@ -11,8 +11,10 @@
#include "common/Schema.h"
#include <google/protobuf/text_format.h>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/lexical_cast.hpp>
#include "common/SystemProperty.h"
#include <optional>
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<int64_t>(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);
}
......
......@@ -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<MetricType> metric_type) {
auto field_meta = FieldMeta(name, id, data_type, dim, metric_type);
this->AddField(std::move(field_meta));
}
......
......@@ -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 <knowhere/index/vector_index/helpers/IndexParameter.h>
#include "exceptions/EasyAssert.h"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册