Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1603 BinaryFlat add 2 Metrics: Substructure and Superstructure #1647

Merged
merged 3 commits into from
Mar 14, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
support c++sdk by lin.xiaojun
Signed-off-by: shengjun.li <shengjun.li@zilliz.com>
  • Loading branch information
shengjun.li committed Mar 13, 2020
commit d3801b0cc2aa8c50246531f085a8d067dd08fe64
3 changes: 3 additions & 0 deletions core/src/db/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "db/Utils.h"

#include <fiu-local.h>

#include <boost/filesystem.hpp>
#include <chrono>
#include <mutex>
Expand Down Expand Up @@ -230,6 +231,8 @@ bool
IsBinaryMetricType(int32_t metric_type) {
return (metric_type == (int32_t)engine::MetricType::HAMMING) ||
(metric_type == (int32_t)engine::MetricType::JACCARD) ||
(metric_type == (int32_t)engine::MetricType::SUBSTRUCTURE) ||
(metric_type == (int32_t)engine::MetricType::SUPERSTRUCTURE) ||
(metric_type == (int32_t)engine::MetricType::TANIMOTO);
}

Expand Down
14 changes: 8 additions & 6 deletions core/src/db/engine/ExecutionEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ enum class EngineType {
};

enum class MetricType {
L2 = 1, // Euclidean Distance
IP = 2, // Cosine Similarity
HAMMING = 3, // Hamming Distance
JACCARD = 4, // Jaccard Distance
TANIMOTO = 5, // Tanimoto Distance
MAX_VALUE = TANIMOTO,
L2 = 1, // Euclidean Distance
IP = 2, // Cosine Similarity
HAMMING = 3, // Hamming Distance
JACCARD = 4, // Jaccard Distance
TANIMOTO = 5, // Tanimoto Distance
SUBSTRUCTURE = 6, // Substructure Distance
SUPERSTRUCTURE = 7, // Superstructure Distance
MAX_VALUE = SUPERSTRUCTURE
};

class ExecutionEngine {
Expand Down
6 changes: 6 additions & 0 deletions core/src/db/engine/ExecutionEngineImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ MappingMetricType(MetricType metric_type, milvus::json& conf) {
case MetricType::TANIMOTO:
conf[knowhere::Metric::TYPE] = knowhere::Metric::TANIMOTO;
break;
case MetricType::SUBSTRUCTURE:
conf[knowhere::Metric::TYPE] = knowhere::Metric::SUBSTRUCTURE;
break;
case MetricType::SUPERSTRUCTURE:
conf[knowhere::Metric::TYPE] = knowhere::Metric::SUPERSTRUCTURE;
break;
default:
return Status(DB_ERROR, "Unsupported metric type");
}
Expand Down
3 changes: 2 additions & 1 deletion core/src/wrapper/ConfAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ HNSWConfAdapter::CheckSearch(milvus::json& oricfg, const IndexType& type) {
bool
BinIDMAPConfAdapter::CheckTrain(milvus::json& oricfg) {
static std::vector<std::string> METRICS{knowhere::Metric::HAMMING, knowhere::Metric::JACCARD,
knowhere::Metric::TANIMOTO};
knowhere::Metric::TANIMOTO, knowhere::Metric::SUBSTRUCTURE,
knowhere::Metric::SUPERSTRUCTURE};

CheckIntByRange(knowhere::meta::DIM, DEFAULT_MIN_DIM, DEFAULT_MAX_DIM);
CheckStrByValues(knowhere::Metric::TYPE, METRICS);
Expand Down
2 changes: 2 additions & 0 deletions sdk/examples/utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ Utils::MetricTypeName(const milvus::MetricType& metric_type) {
case milvus::MetricType::HAMMING:return "Hamming distance";
case milvus::MetricType::JACCARD:return "Jaccard distance";
case milvus::MetricType::TANIMOTO:return "Tanimoto distance";
case milvus::MetricType::SUBSTRUCTURE:return "Substructure distance";
case milvus::MetricType::SUPERSTRUCTURE:return "Superstructure distance";
default:return "Unknown metric type";
}
}
Expand Down
2 changes: 2 additions & 0 deletions sdk/include/MilvusApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ enum class MetricType {
HAMMING = 3, // Hamming Distance
JACCARD = 4, // Jaccard Distance
TANIMOTO = 5, // Tanimoto Distance
SUBSTRUCTURE = 6, // Substructure Distance
SUPERSTRUCTURE = 7, // Superstructure Distance
};

/**
Expand Down