Skip to content

Commit 9a4761d

Browse files
authored
Remove binary metrics TANIMOTO/SUPERSTRUCTURE/SUBSTRUCTURE (milvus-io#25708)
Signed-off-by: Yudong Cai <yudong.cai@zilliz.com>
1 parent bccdef1 commit 9a4761d

31 files changed

Lines changed: 51 additions & 271 deletions

internal/core/src/common/RangeSearchHelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ CheckRangeSearchParam(float radius,
125125
} else {
126126
AssertInfo(range_filter < radius,
127127
"range_filter must be less than radius for "
128-
"L2/HAMMING/JACCARD/TANIMOTO");
128+
"L2/HAMMING/JACCARD");
129129
}
130130
}
131131

internal/core/src/query/deprecated/ValidationUtil.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,7 @@ ValidateIndexMetricType(const std::string_view metric_type,
362362
} else if (index_type == knowhere::IndexEnum::INDEX_FAISS_BIN_IVFFLAT) {
363363
// binary
364364
if (metric_type != knowhere::Metric::HAMMING &&
365-
metric_type != knowhere::Metric::JACCARD &&
366-
metric_type != knowhere::Metric::TANIMOTO) {
365+
metric_type != knowhere::Metric::JACCARD) {
367366
std::string msg = "Index metric type " + metric_type +
368367
" does not match index type " + index_type;
369368
LOG_SERVER_ERROR_ << msg;
@@ -398,8 +397,7 @@ ValidateSearchMetricType(const std::string_view metric_type, bool is_binary) {
398397
} else {
399398
// float
400399
if (metric_type == knowhere::Metric::HAMMING ||
401-
metric_type == knowhere::Metric::JACCARD ||
402-
metric_type == knowhere::Metric::TANIMOTO) {
400+
metric_type == knowhere::Metric::JACCARD) {
403401
std::string msg =
404402
"Cannot search float entities with index metric type " +
405403
metric_type;

internal/core/unittest/test_index_wrapper.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ INSTANTIATE_TEST_CASE_P(
123123
knowhere::metric::L2),
124124
std::pair(knowhere::IndexEnum::INDEX_FAISS_BIN_IVFFLAT,
125125
knowhere::metric::JACCARD),
126-
std::pair(knowhere::IndexEnum::INDEX_FAISS_BIN_IVFFLAT,
127-
knowhere::metric::TANIMOTO),
128126
std::pair(knowhere::IndexEnum::INDEX_FAISS_BIN_IDMAP,
129127
knowhere::metric::JACCARD),
130128
std::pair(knowhere::IndexEnum::INDEX_HNSW, knowhere::metric::L2)));

internal/core/unittest/test_indexing.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,6 @@ INSTANTIATE_TEST_CASE_P(
360360
knowhere::metric::L2),
361361
std::pair(knowhere::IndexEnum::INDEX_FAISS_BIN_IVFFLAT,
362362
knowhere::metric::JACCARD),
363-
std::pair(knowhere::IndexEnum::INDEX_FAISS_BIN_IVFFLAT,
364-
knowhere::metric::TANIMOTO),
365363
std::pair(knowhere::IndexEnum::INDEX_FAISS_BIN_IDMAP,
366364
knowhere::metric::JACCARD),
367365
#ifdef BUILD_DISK_ANN

internal/core/unittest/test_range_search_sort.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ INSTANTIATE_TEST_CASE_P(RangeSearchSortParameters,
162162
::testing::Values(knowhere::metric::L2,
163163
knowhere::metric::IP,
164164
knowhere::metric::JACCARD,
165-
knowhere::metric::TANIMOTO,
166165
knowhere::metric::HAMMING));
167166

168167
TEST_P(RangeSearchSortTest, CheckRangeSearchSort) {

internal/core/unittest/test_similarity_corelation.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515

1616
TEST(SimilarityCorelation, Naive) {
1717
ASSERT_TRUE(milvus::PositivelyRelated(knowhere::metric::IP));
18+
ASSERT_TRUE(milvus::PositivelyRelated(knowhere::metric::COSINE));
1819

1920
ASSERT_FALSE(milvus::PositivelyRelated(knowhere::metric::L2));
2021
ASSERT_FALSE(milvus::PositivelyRelated(knowhere::metric::HAMMING));
2122
ASSERT_FALSE(milvus::PositivelyRelated(knowhere::metric::JACCARD));
22-
ASSERT_FALSE(milvus::PositivelyRelated(knowhere::metric::TANIMOTO));
23-
ASSERT_FALSE(milvus::PositivelyRelated(knowhere::metric::SUBSTRUCTURE));
24-
ASSERT_FALSE(milvus::PositivelyRelated(knowhere::metric::SUPERSTRUCTURE));
2523
}

internal/proxy/util.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
"github.com/milvus-io/milvus/pkg/util/commonpbutil"
4444
"github.com/milvus-io/milvus/pkg/util/crypto"
4545
"github.com/milvus-io/milvus/pkg/util/merr"
46+
"github.com/milvus-io/milvus/pkg/util/metric"
4647
"github.com/milvus-io/milvus/pkg/util/tsoutil"
4748
"github.com/milvus-io/milvus/pkg/util/typeutil"
4849
)
@@ -439,11 +440,11 @@ func isVector(dataType schemapb.DataType) (bool, error) {
439440
func validateMetricType(dataType schemapb.DataType, metricTypeStrRaw string) error {
440441
metricTypeStr := strings.ToUpper(metricTypeStrRaw)
441442
switch metricTypeStr {
442-
case "L2", "IP":
443+
case metric.L2, metric.IP, metric.COSINE:
443444
if dataType == schemapb.DataType_FloatVector {
444445
return nil
445446
}
446-
case "JACCARD", "HAMMING", "TANIMOTO", "SUBSTRUCTURE", "SUBPERSTURCTURE":
447+
case metric.JACCARD, metric.HAMMING:
447448
if dataType == schemapb.DataType_BinaryVector {
448449
return nil
449450
}

internal/querynodev2/delegator/delegator_data_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
"github.com/milvus-io/milvus/pkg/common"
4040
"github.com/milvus-io/milvus/pkg/mq/msgstream"
4141
"github.com/milvus-io/milvus/pkg/util/commonpbutil"
42+
"github.com/milvus-io/milvus/pkg/util/metric"
4243
"github.com/milvus-io/milvus/pkg/util/paramtable"
4344
)
4445

@@ -117,7 +118,7 @@ func (s *DelegatorDataSuite) SetupTest() {
117118
},
118119
{
119120
Key: common.MetricTypeKey,
120-
Value: "TANIMOTO",
121+
Value: metric.JACCARD,
121122
},
122123
},
123124
},

internal/querynodev2/delegator/delegator_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import (
4242
"github.com/milvus-io/milvus/pkg/mq/msgstream"
4343
"github.com/milvus-io/milvus/pkg/util/commonpbutil"
4444
"github.com/milvus-io/milvus/pkg/util/merr"
45+
"github.com/milvus-io/milvus/pkg/util/metric"
4546
"github.com/milvus-io/milvus/pkg/util/paramtable"
4647
)
4748

@@ -139,7 +140,7 @@ func (s *DelegatorSuite) SetupTest() {
139140
},
140141
{
141142
Key: common.MetricTypeKey,
142-
Value: "TANIMOTO",
143+
Value: metric.JACCARD,
143144
},
144145
},
145146
},

internal/querynodev2/segments/mock_data.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import (
4646
"github.com/milvus-io/milvus/pkg/log"
4747
"github.com/milvus-io/milvus/pkg/mq/msgstream"
4848
"github.com/milvus-io/milvus/pkg/util/funcutil"
49+
"github.com/milvus-io/milvus/pkg/util/metric"
4950
"github.com/milvus-io/milvus/pkg/util/paramtable"
5051
"github.com/milvus-io/milvus/pkg/util/typeutil"
5152
)
@@ -59,12 +60,6 @@ const (
5960
IndexFaissBinIVFFlat = "BIN_IVF_FLAT"
6061
IndexHNSW = "HNSW"
6162

62-
L2 = "L2"
63-
IP = "IP"
64-
hamming = "HAMMING"
65-
Jaccard = "JACCARD"
66-
tanimoto = "TANIMOTO"
67-
6863
nlist = 100
6964
m = 4
7065
nbits = 8
@@ -79,7 +74,7 @@ const (
7974
timestampFieldID = 1
8075
metricTypeKey = common.MetricTypeKey
8176
defaultDim = 128
82-
defaultMetricType = "L2"
77+
defaultMetricType = metric.L2
8378

8479
dimKey = common.DimKey
8580

@@ -113,7 +108,7 @@ var simpleFloatVecField = vecFieldParam{
113108
var simpleBinVecField = vecFieldParam{
114109
id: 101,
115110
dim: defaultDim,
116-
metricType: Jaccard,
111+
metricType: metric.JACCARD,
117112
vecType: schemapb.DataType_BinaryVector,
118113
fieldName: "binVectorField",
119114
}

0 commit comments

Comments
 (0)