blob: 6f54f13db0cdaa8f32602c2bdd872c03a809b821 [file] [log] [blame]
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License 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.
#include "vector/metric.h"
#include <string>
#include "vec/functions/array/function_array_distance.h"
namespace doris::segment_v2 {
std::string metric_to_string(Metric metric) {
switch (metric) {
case Metric::L2:
return vectorized::L2Distance::name;
case Metric::IP:
return vectorized::InnerProduct::name;
default:
return "UNKNOWN";
}
}
Metric string_to_metric(const std::string& metric) {
if (metric == vectorized::L2Distance::name) {
return Metric::L2;
} else if (metric == vectorized::InnerProduct::name) {
return Metric::IP;
} else {
return Metric::UNKNOWN;
}
}
} // namespace doris::segment_v2