mirror of https://github.com/milvus-io/milvus.git
Fix flat unsupported bug
Signed-off-by: FluorineDog <guilin.gou@zilliz.com>pull/4973/head^2
parent
bfb7ca0df6
commit
1446cd5453
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue