Rename FaissMetricTypeToString to MetricTypeToString (#12767)

Signed-off-by: yudong.cai <yudong.cai@zilliz.com>
This commit is contained in:
Cai Yudong 2021-12-07 10:13:53 +08:00 committed by GitHub
parent 720478abd5
commit b053317545
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 24 deletions

View File

@ -59,8 +59,8 @@ raw_search(MetricType metric_type,
// only matched ids will be chosen, not to use heap
binary_distance_knn_mc(metric_type, x, xb, n, ntotal, k, code_size, D, labels, bitset);
} else {
std::string msg = std::string("do binary search with unsupported metric type: ") +
segcore::FaissMetricTypeToString(metric_type);
std::string msg =
std::string("binary search not support metric type: ") + segcore::MetricTypeToString(metric_type);
PanicInfo(msg);
}
}

View File

@ -13,12 +13,13 @@
#include <string>
#include <exception>
#include <stdexcept>
#include "index/thirdparty/faiss/MetricType.h"
namespace milvus {
namespace segcore {
namespace milvus::segcore {
static inline constexpr const char*
FaissMetricTypeToString(faiss::MetricType metric_type) {
MetricTypeToString(faiss::MetricType metric_type) {
switch (metric_type) {
case faiss::MetricType::METRIC_INNER_PRODUCT:
return "METRIC_INNER_PRODUCT";
@ -50,5 +51,5 @@ FaissMetricTypeToString(faiss::MetricType metric_type) {
return "Unsupported";
}
}
} // namespace segcore
} // namespace milvus
} // namespace milvus::segcore

View File

@ -9,27 +9,27 @@
// 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 <gtest/gtest.h>
#include <string.h>
#include "index/thirdparty/faiss/MetricType.h"
#include "segcore/Utils.h"
#include <string.h>
#include <gtest/gtest.h>
TEST(Util, FaissMetricTypeToString) {
using namespace milvus::segcore;
using namespace faiss;
ASSERT_EQ(0, strcmp(FaissMetricTypeToString(faiss::MetricType::METRIC_INNER_PRODUCT), "METRIC_INNER_PRODUCT"));
ASSERT_EQ(0, strcmp(FaissMetricTypeToString(faiss::MetricType::METRIC_L2), "METRIC_L2"));
ASSERT_EQ(0, strcmp(FaissMetricTypeToString(faiss::MetricType::METRIC_L1), "METRIC_L1"));
ASSERT_EQ(0, strcmp(FaissMetricTypeToString(faiss::MetricType::METRIC_Linf), "METRIC_Linf"));
ASSERT_EQ(0, strcmp(FaissMetricTypeToString(faiss::MetricType::METRIC_Lp), "METRIC_Lp"));
ASSERT_EQ(0, strcmp(FaissMetricTypeToString(faiss::MetricType::METRIC_Jaccard), "METRIC_Jaccard"));
ASSERT_EQ(0, strcmp(FaissMetricTypeToString(faiss::MetricType::METRIC_Tanimoto), "METRIC_Tanimoto"));
ASSERT_EQ(0, strcmp(FaissMetricTypeToString(faiss::MetricType::METRIC_Hamming), "METRIC_Hamming"));
ASSERT_EQ(0, strcmp(FaissMetricTypeToString(faiss::MetricType::METRIC_Substructure), "METRIC_Substructure"));
ASSERT_EQ(0, strcmp(FaissMetricTypeToString(faiss::MetricType::METRIC_Superstructure), "METRIC_Superstructure"));
ASSERT_EQ(0, strcmp(FaissMetricTypeToString(faiss::MetricType::METRIC_Canberra), "METRIC_Canberra"));
ASSERT_EQ(0, strcmp(FaissMetricTypeToString(faiss::MetricType::METRIC_BrayCurtis), "METRIC_BrayCurtis"));
ASSERT_EQ(0, strcmp(FaissMetricTypeToString(faiss::MetricType::METRIC_JensenShannon), "METRIC_JensenShannon"));
ASSERT_EQ(MetricTypeToString(MetricType::METRIC_INNER_PRODUCT), "METRIC_INNER_PRODUCT");
ASSERT_EQ(MetricTypeToString(MetricType::METRIC_L2), "METRIC_L2");
ASSERT_EQ(MetricTypeToString(MetricType::METRIC_L1), "METRIC_L1");
ASSERT_EQ(MetricTypeToString(MetricType::METRIC_Linf), "METRIC_Linf");
ASSERT_EQ(MetricTypeToString(MetricType::METRIC_Lp), "METRIC_Lp");
ASSERT_EQ(MetricTypeToString(MetricType::METRIC_Jaccard), "METRIC_Jaccard");
ASSERT_EQ(MetricTypeToString(MetricType::METRIC_Tanimoto), "METRIC_Tanimoto");
ASSERT_EQ(MetricTypeToString(MetricType::METRIC_Hamming), "METRIC_Hamming");
ASSERT_EQ(MetricTypeToString(MetricType::METRIC_Substructure), "METRIC_Substructure");
ASSERT_EQ(MetricTypeToString(MetricType::METRIC_Superstructure), "METRIC_Superstructure");
ASSERT_EQ(MetricTypeToString(MetricType::METRIC_Canberra), "METRIC_Canberra");
ASSERT_EQ(MetricTypeToString(MetricType::METRIC_BrayCurtis), "METRIC_BrayCurtis");
ASSERT_EQ(MetricTypeToString(MetricType::METRIC_JensenShannon), "METRIC_JensenShannon");
}