Remove binary metrics TANIMOTO/SUPERSTRUCTURE/SUBSTRUCTURE (#25708)

Signed-off-by: Yudong Cai <yudong.cai@zilliz.com>
This commit is contained in:
Cai Yudong 2023-07-19 16:16:58 +08:00 committed by GitHub
parent bccdef1ad7
commit 9a4761dcc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 51 additions and 271 deletions

View File

@ -125,7 +125,7 @@ CheckRangeSearchParam(float radius,
} else { } else {
AssertInfo(range_filter < radius, AssertInfo(range_filter < radius,
"range_filter must be less than radius for " "range_filter must be less than radius for "
"L2/HAMMING/JACCARD/TANIMOTO"); "L2/HAMMING/JACCARD");
} }
} }

View File

@ -362,8 +362,7 @@ ValidateIndexMetricType(const std::string_view metric_type,
} else if (index_type == knowhere::IndexEnum::INDEX_FAISS_BIN_IVFFLAT) { } else if (index_type == knowhere::IndexEnum::INDEX_FAISS_BIN_IVFFLAT) {
// binary // binary
if (metric_type != knowhere::Metric::HAMMING && if (metric_type != knowhere::Metric::HAMMING &&
metric_type != knowhere::Metric::JACCARD && metric_type != knowhere::Metric::JACCARD) {
metric_type != knowhere::Metric::TANIMOTO) {
std::string msg = "Index metric type " + metric_type + std::string msg = "Index metric type " + metric_type +
" does not match index type " + index_type; " does not match index type " + index_type;
LOG_SERVER_ERROR_ << msg; LOG_SERVER_ERROR_ << msg;
@ -398,8 +397,7 @@ ValidateSearchMetricType(const std::string_view metric_type, bool is_binary) {
} else { } else {
// float // float
if (metric_type == knowhere::Metric::HAMMING || if (metric_type == knowhere::Metric::HAMMING ||
metric_type == knowhere::Metric::JACCARD || metric_type == knowhere::Metric::JACCARD) {
metric_type == knowhere::Metric::TANIMOTO) {
std::string msg = std::string msg =
"Cannot search float entities with index metric type " + "Cannot search float entities with index metric type " +
metric_type; metric_type;

View File

@ -123,8 +123,6 @@ INSTANTIATE_TEST_CASE_P(
knowhere::metric::L2), knowhere::metric::L2),
std::pair(knowhere::IndexEnum::INDEX_FAISS_BIN_IVFFLAT, std::pair(knowhere::IndexEnum::INDEX_FAISS_BIN_IVFFLAT,
knowhere::metric::JACCARD), knowhere::metric::JACCARD),
std::pair(knowhere::IndexEnum::INDEX_FAISS_BIN_IVFFLAT,
knowhere::metric::TANIMOTO),
std::pair(knowhere::IndexEnum::INDEX_FAISS_BIN_IDMAP, std::pair(knowhere::IndexEnum::INDEX_FAISS_BIN_IDMAP,
knowhere::metric::JACCARD), knowhere::metric::JACCARD),
std::pair(knowhere::IndexEnum::INDEX_HNSW, knowhere::metric::L2))); std::pair(knowhere::IndexEnum::INDEX_HNSW, knowhere::metric::L2)));

View File

@ -360,8 +360,6 @@ INSTANTIATE_TEST_CASE_P(
knowhere::metric::L2), knowhere::metric::L2),
std::pair(knowhere::IndexEnum::INDEX_FAISS_BIN_IVFFLAT, std::pair(knowhere::IndexEnum::INDEX_FAISS_BIN_IVFFLAT,
knowhere::metric::JACCARD), knowhere::metric::JACCARD),
std::pair(knowhere::IndexEnum::INDEX_FAISS_BIN_IVFFLAT,
knowhere::metric::TANIMOTO),
std::pair(knowhere::IndexEnum::INDEX_FAISS_BIN_IDMAP, std::pair(knowhere::IndexEnum::INDEX_FAISS_BIN_IDMAP,
knowhere::metric::JACCARD), knowhere::metric::JACCARD),
#ifdef BUILD_DISK_ANN #ifdef BUILD_DISK_ANN

View File

@ -162,7 +162,6 @@ INSTANTIATE_TEST_CASE_P(RangeSearchSortParameters,
::testing::Values(knowhere::metric::L2, ::testing::Values(knowhere::metric::L2,
knowhere::metric::IP, knowhere::metric::IP,
knowhere::metric::JACCARD, knowhere::metric::JACCARD,
knowhere::metric::TANIMOTO,
knowhere::metric::HAMMING)); knowhere::metric::HAMMING));
TEST_P(RangeSearchSortTest, CheckRangeSearchSort) { TEST_P(RangeSearchSortTest, CheckRangeSearchSort) {

View File

@ -15,11 +15,9 @@
TEST(SimilarityCorelation, Naive) { TEST(SimilarityCorelation, Naive) {
ASSERT_TRUE(milvus::PositivelyRelated(knowhere::metric::IP)); ASSERT_TRUE(milvus::PositivelyRelated(knowhere::metric::IP));
ASSERT_TRUE(milvus::PositivelyRelated(knowhere::metric::COSINE));
ASSERT_FALSE(milvus::PositivelyRelated(knowhere::metric::L2)); ASSERT_FALSE(milvus::PositivelyRelated(knowhere::metric::L2));
ASSERT_FALSE(milvus::PositivelyRelated(knowhere::metric::HAMMING)); ASSERT_FALSE(milvus::PositivelyRelated(knowhere::metric::HAMMING));
ASSERT_FALSE(milvus::PositivelyRelated(knowhere::metric::JACCARD)); ASSERT_FALSE(milvus::PositivelyRelated(knowhere::metric::JACCARD));
ASSERT_FALSE(milvus::PositivelyRelated(knowhere::metric::TANIMOTO));
ASSERT_FALSE(milvus::PositivelyRelated(knowhere::metric::SUBSTRUCTURE));
ASSERT_FALSE(milvus::PositivelyRelated(knowhere::metric::SUPERSTRUCTURE));
} }

View File

@ -43,6 +43,7 @@ import (
"github.com/milvus-io/milvus/pkg/util/commonpbutil" "github.com/milvus-io/milvus/pkg/util/commonpbutil"
"github.com/milvus-io/milvus/pkg/util/crypto" "github.com/milvus-io/milvus/pkg/util/crypto"
"github.com/milvus-io/milvus/pkg/util/merr" "github.com/milvus-io/milvus/pkg/util/merr"
"github.com/milvus-io/milvus/pkg/util/metric"
"github.com/milvus-io/milvus/pkg/util/tsoutil" "github.com/milvus-io/milvus/pkg/util/tsoutil"
"github.com/milvus-io/milvus/pkg/util/typeutil" "github.com/milvus-io/milvus/pkg/util/typeutil"
) )
@ -439,11 +440,11 @@ func isVector(dataType schemapb.DataType) (bool, error) {
func validateMetricType(dataType schemapb.DataType, metricTypeStrRaw string) error { func validateMetricType(dataType schemapb.DataType, metricTypeStrRaw string) error {
metricTypeStr := strings.ToUpper(metricTypeStrRaw) metricTypeStr := strings.ToUpper(metricTypeStrRaw)
switch metricTypeStr { switch metricTypeStr {
case "L2", "IP": case metric.L2, metric.IP, metric.COSINE:
if dataType == schemapb.DataType_FloatVector { if dataType == schemapb.DataType_FloatVector {
return nil return nil
} }
case "JACCARD", "HAMMING", "TANIMOTO", "SUBSTRUCTURE", "SUBPERSTURCTURE": case metric.JACCARD, metric.HAMMING:
if dataType == schemapb.DataType_BinaryVector { if dataType == schemapb.DataType_BinaryVector {
return nil return nil
} }

View File

@ -39,6 +39,7 @@ import (
"github.com/milvus-io/milvus/pkg/common" "github.com/milvus-io/milvus/pkg/common"
"github.com/milvus-io/milvus/pkg/mq/msgstream" "github.com/milvus-io/milvus/pkg/mq/msgstream"
"github.com/milvus-io/milvus/pkg/util/commonpbutil" "github.com/milvus-io/milvus/pkg/util/commonpbutil"
"github.com/milvus-io/milvus/pkg/util/metric"
"github.com/milvus-io/milvus/pkg/util/paramtable" "github.com/milvus-io/milvus/pkg/util/paramtable"
) )
@ -117,7 +118,7 @@ func (s *DelegatorDataSuite) SetupTest() {
}, },
{ {
Key: common.MetricTypeKey, Key: common.MetricTypeKey,
Value: "TANIMOTO", Value: metric.JACCARD,
}, },
}, },
}, },

View File

@ -42,6 +42,7 @@ import (
"github.com/milvus-io/milvus/pkg/mq/msgstream" "github.com/milvus-io/milvus/pkg/mq/msgstream"
"github.com/milvus-io/milvus/pkg/util/commonpbutil" "github.com/milvus-io/milvus/pkg/util/commonpbutil"
"github.com/milvus-io/milvus/pkg/util/merr" "github.com/milvus-io/milvus/pkg/util/merr"
"github.com/milvus-io/milvus/pkg/util/metric"
"github.com/milvus-io/milvus/pkg/util/paramtable" "github.com/milvus-io/milvus/pkg/util/paramtable"
) )
@ -139,7 +140,7 @@ func (s *DelegatorSuite) SetupTest() {
}, },
{ {
Key: common.MetricTypeKey, Key: common.MetricTypeKey,
Value: "TANIMOTO", Value: metric.JACCARD,
}, },
}, },
}, },

View File

@ -46,6 +46,7 @@ import (
"github.com/milvus-io/milvus/pkg/log" "github.com/milvus-io/milvus/pkg/log"
"github.com/milvus-io/milvus/pkg/mq/msgstream" "github.com/milvus-io/milvus/pkg/mq/msgstream"
"github.com/milvus-io/milvus/pkg/util/funcutil" "github.com/milvus-io/milvus/pkg/util/funcutil"
"github.com/milvus-io/milvus/pkg/util/metric"
"github.com/milvus-io/milvus/pkg/util/paramtable" "github.com/milvus-io/milvus/pkg/util/paramtable"
"github.com/milvus-io/milvus/pkg/util/typeutil" "github.com/milvus-io/milvus/pkg/util/typeutil"
) )
@ -59,12 +60,6 @@ const (
IndexFaissBinIVFFlat = "BIN_IVF_FLAT" IndexFaissBinIVFFlat = "BIN_IVF_FLAT"
IndexHNSW = "HNSW" IndexHNSW = "HNSW"
L2 = "L2"
IP = "IP"
hamming = "HAMMING"
Jaccard = "JACCARD"
tanimoto = "TANIMOTO"
nlist = 100 nlist = 100
m = 4 m = 4
nbits = 8 nbits = 8
@ -79,7 +74,7 @@ const (
timestampFieldID = 1 timestampFieldID = 1
metricTypeKey = common.MetricTypeKey metricTypeKey = common.MetricTypeKey
defaultDim = 128 defaultDim = 128
defaultMetricType = "L2" defaultMetricType = metric.L2
dimKey = common.DimKey dimKey = common.DimKey
@ -113,7 +108,7 @@ var simpleFloatVecField = vecFieldParam{
var simpleBinVecField = vecFieldParam{ var simpleBinVecField = vecFieldParam{
id: 101, id: 101,
dim: defaultDim, dim: defaultDim,
metricType: Jaccard, metricType: metric.JACCARD,
vecType: schemapb.DataType_BinaryVector, vecType: schemapb.DataType_BinaryVector,
fieldName: "binVectorField", fieldName: "binVectorField",
} }

View File

@ -28,6 +28,7 @@ import (
"github.com/milvus-io/milvus/internal/storage" "github.com/milvus-io/milvus/internal/storage"
"github.com/milvus-io/milvus/internal/util/initcore" "github.com/milvus-io/milvus/internal/util/initcore"
"github.com/milvus-io/milvus/pkg/util/funcutil" "github.com/milvus-io/milvus/pkg/util/funcutil"
"github.com/milvus-io/milvus/pkg/util/metric"
"github.com/milvus-io/milvus/pkg/util/paramtable" "github.com/milvus-io/milvus/pkg/util/paramtable"
) )
@ -234,7 +235,7 @@ func (suite *SegmentLoaderSuite) TestLoadWithIndex() {
vecFields[0], vecFields[0],
msgLength, msgLength,
IndexFaissIVFFlat, IndexFaissIVFFlat,
L2, metric.L2,
suite.chunkManager, suite.chunkManager,
) )
suite.NoError(err) suite.NoError(err)
@ -401,7 +402,7 @@ func (suite *SegmentLoaderSuite) TestPatchEntryNum() {
vecFields[0], vecFields[0],
msgLength, msgLength,
IndexFaissIVFFlat, IndexFaissIVFFlat,
L2, metric.L2,
suite.chunkManager, suite.chunkManager,
) )
suite.NoError(err) suite.NoError(err)

View File

@ -12,6 +12,7 @@ import (
storage "github.com/milvus-io/milvus/internal/storage" storage "github.com/milvus-io/milvus/internal/storage"
"github.com/milvus-io/milvus/internal/util/initcore" "github.com/milvus-io/milvus/internal/util/initcore"
"github.com/milvus-io/milvus/pkg/util/funcutil" "github.com/milvus-io/milvus/pkg/util/funcutil"
"github.com/milvus-io/milvus/pkg/util/metric"
"github.com/milvus-io/milvus/pkg/util/paramtable" "github.com/milvus-io/milvus/pkg/util/paramtable"
) )
@ -187,7 +188,7 @@ func (suite *SegmentSuite) TestValidateIndexedFieldsData() {
// with index but doesn't have raw data // with index but doesn't have raw data
index := suite.sealed.GetIndex(101) index := suite.sealed.GetIndex(101)
_, indexParams := genIndexParams(IndexHNSW, L2) _, indexParams := genIndexParams(IndexHNSW, metric.L2)
index.IndexInfo.IndexParams = funcutil.Map2KeyValuePair(indexParams) index.IndexInfo.IndexParams = funcutil.Map2KeyValuePair(indexParams)
DeleteSegment(suite.sealed) DeleteSegment(suite.sealed)
suite.True(suite.sealed.ExistIndex(101)) suite.True(suite.sealed.ExistIndex(101))

View File

@ -45,6 +45,7 @@ import (
"github.com/milvus-io/milvus/pkg/util/etcd" "github.com/milvus-io/milvus/pkg/util/etcd"
"github.com/milvus-io/milvus/pkg/util/funcutil" "github.com/milvus-io/milvus/pkg/util/funcutil"
"github.com/milvus-io/milvus/pkg/util/merr" "github.com/milvus-io/milvus/pkg/util/merr"
"github.com/milvus-io/milvus/pkg/util/metric"
"github.com/milvus-io/milvus/pkg/util/metricsinfo" "github.com/milvus-io/milvus/pkg/util/metricsinfo"
"github.com/milvus-io/milvus/pkg/util/paramtable" "github.com/milvus-io/milvus/pkg/util/paramtable"
"github.com/milvus-io/milvus/pkg/util/typeutil" "github.com/milvus-io/milvus/pkg/util/typeutil"
@ -478,7 +479,7 @@ func (suite *ServiceSuite) genSegmentLoadInfos(schema *schemapb.CollectionSchema
vecFieldIDs[0], vecFieldIDs[0],
1000, 1000,
segments.IndexFaissIVFFlat, segments.IndexFaissIVFFlat,
segments.L2, metric.L2,
suite.node.vectorStorage, suite.node.vectorStorage,
) )
suite.Require().NoError(err) suite.Require().NoError(err)

View File

@ -12,6 +12,7 @@ import (
"github.com/milvus-io/milvus/internal/storage" "github.com/milvus-io/milvus/internal/storage"
"github.com/milvus-io/milvus/pkg/common" "github.com/milvus-io/milvus/pkg/common"
"github.com/milvus-io/milvus/pkg/util/funcutil" "github.com/milvus-io/milvus/pkg/util/funcutil"
"github.com/milvus-io/milvus/pkg/util/metric"
) )
type indexTestCase struct { type indexTestCase struct {
@ -201,7 +202,7 @@ func genFloatVecIndexCases(dtype schemapb.DataType) []indexTestCase {
typeParams: nil, typeParams: nil,
indexParams: map[string]string{ indexParams: map[string]string{
common.IndexTypeKey: IndexFaissIVFPQ, common.IndexTypeKey: IndexFaissIVFPQ,
common.MetricTypeKey: L2, common.MetricTypeKey: metric.L2,
common.DimKey: strconv.Itoa(dim), common.DimKey: strconv.Itoa(dim),
"nlist": strconv.Itoa(nlist), "nlist": strconv.Itoa(nlist),
"m": strconv.Itoa(m), "m": strconv.Itoa(m),
@ -213,7 +214,7 @@ func genFloatVecIndexCases(dtype schemapb.DataType) []indexTestCase {
typeParams: nil, typeParams: nil,
indexParams: map[string]string{ indexParams: map[string]string{
common.IndexTypeKey: IndexFaissIVFFlat, common.IndexTypeKey: IndexFaissIVFFlat,
common.MetricTypeKey: L2, common.MetricTypeKey: metric.L2,
common.DimKey: strconv.Itoa(dim), common.DimKey: strconv.Itoa(dim),
"nlist": strconv.Itoa(nlist), "nlist": strconv.Itoa(nlist),
}, },
@ -228,7 +229,7 @@ func genBinaryVecIndexCases(dtype schemapb.DataType) []indexTestCase {
typeParams: nil, typeParams: nil,
indexParams: map[string]string{ indexParams: map[string]string{
common.IndexTypeKey: IndexFaissBinIVFFlat, common.IndexTypeKey: IndexFaissBinIVFFlat,
common.MetricTypeKey: Jaccard, common.MetricTypeKey: metric.JACCARD,
common.DimKey: strconv.Itoa(dim), common.DimKey: strconv.Itoa(dim),
"nlist": strconv.Itoa(nlist), "nlist": strconv.Itoa(nlist),
"nbits": strconv.Itoa(nbits), "nbits": strconv.Itoa(nbits),

View File

@ -8,6 +8,7 @@ import (
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb" "github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
"github.com/milvus-io/milvus/pkg/common" "github.com/milvus-io/milvus/pkg/common"
"github.com/milvus-io/milvus/pkg/util/metric"
"github.com/milvus-io/milvus/pkg/util/paramtable" "github.com/milvus-io/milvus/pkg/util/paramtable"
) )
@ -22,13 +23,6 @@ const (
IndexHNSW = "HNSW" IndexHNSW = "HNSW"
// metric type
L2 = "L2"
IP = "IP"
hamming = "HAMMING"
Jaccard = "JACCARD"
tanimoto = "TANIMOTO"
dim = 8 dim = 8
nlist = 100 nlist = 100
m = 4 m = 4
@ -50,26 +44,25 @@ type vecTestCase struct {
func generateFloatVectorTestCases() []vecTestCase { func generateFloatVectorTestCases() []vecTestCase {
return []vecTestCase{ return []vecTestCase{
{IndexFaissIDMap, L2, false, schemapb.DataType_FloatVector}, {IndexFaissIDMap, metric.L2, false, schemapb.DataType_FloatVector},
{IndexFaissIDMap, IP, false, schemapb.DataType_FloatVector}, {IndexFaissIDMap, metric.IP, false, schemapb.DataType_FloatVector},
{IndexFaissIVFFlat, L2, false, schemapb.DataType_FloatVector}, {IndexFaissIVFFlat, metric.L2, false, schemapb.DataType_FloatVector},
{IndexFaissIVFFlat, IP, false, schemapb.DataType_FloatVector}, {IndexFaissIVFFlat, metric.IP, false, schemapb.DataType_FloatVector},
{IndexFaissIVFPQ, L2, false, schemapb.DataType_FloatVector}, {IndexFaissIVFPQ, metric.L2, false, schemapb.DataType_FloatVector},
{IndexFaissIVFPQ, IP, false, schemapb.DataType_FloatVector}, {IndexFaissIVFPQ, metric.IP, false, schemapb.DataType_FloatVector},
{IndexFaissIVFSQ8, L2, false, schemapb.DataType_FloatVector}, {IndexFaissIVFSQ8, metric.L2, false, schemapb.DataType_FloatVector},
{IndexFaissIVFSQ8, IP, false, schemapb.DataType_FloatVector}, {IndexFaissIVFSQ8, metric.IP, false, schemapb.DataType_FloatVector},
{IndexHNSW, L2, false, schemapb.DataType_FloatVector}, {IndexHNSW, metric.L2, false, schemapb.DataType_FloatVector},
{IndexHNSW, IP, false, schemapb.DataType_FloatVector}, {IndexHNSW, metric.IP, false, schemapb.DataType_FloatVector},
} }
} }
func generateBinaryVectorTestCases() []vecTestCase { func generateBinaryVectorTestCases() []vecTestCase {
return []vecTestCase{ return []vecTestCase{
{IndexFaissBinIVFFlat, Jaccard, true, schemapb.DataType_BinaryVector}, {IndexFaissBinIVFFlat, metric.JACCARD, true, schemapb.DataType_BinaryVector},
{IndexFaissBinIVFFlat, hamming, true, schemapb.DataType_BinaryVector}, {IndexFaissBinIVFFlat, metric.HAMMING, true, schemapb.DataType_BinaryVector},
{IndexFaissBinIVFFlat, tanimoto, true, schemapb.DataType_BinaryVector}, {IndexFaissBinIDMap, metric.JACCARD, true, schemapb.DataType_BinaryVector},
{IndexFaissBinIDMap, Jaccard, true, schemapb.DataType_BinaryVector}, {IndexFaissBinIDMap, metric.HAMMING, true, schemapb.DataType_BinaryVector},
{IndexFaissBinIDMap, hamming, true, schemapb.DataType_BinaryVector},
} }
} }

View File

@ -31,7 +31,6 @@ func Test_binFlatChecker_CheckTrain(t *testing.T) {
DIM: strconv.Itoa(128), DIM: strconv.Itoa(128),
Metric: metric.COSINE, Metric: metric.COSINE,
} }
p4 := map[string]string{ p4 := map[string]string{
DIM: strconv.Itoa(128), DIM: strconv.Itoa(128),
Metric: metric.HAMMING, Metric: metric.HAMMING,
@ -40,18 +39,6 @@ func Test_binFlatChecker_CheckTrain(t *testing.T) {
DIM: strconv.Itoa(128), DIM: strconv.Itoa(128),
Metric: metric.JACCARD, Metric: metric.JACCARD,
} }
p6 := map[string]string{
DIM: strconv.Itoa(128),
Metric: metric.TANIMOTO,
}
p7 := map[string]string{
DIM: strconv.Itoa(128),
Metric: metric.SUBSTRUCTURE,
}
p8 := map[string]string{
DIM: strconv.Itoa(128),
Metric: metric.SUPERSTRUCTURE,
}
cases := []struct { cases := []struct {
params map[string]string params map[string]string
@ -64,9 +51,6 @@ func Test_binFlatChecker_CheckTrain(t *testing.T) {
{p3, false}, {p3, false},
{p4, true}, {p4, true},
{p5, true}, {p5, true},
{p6, true},
{p7, true},
{p8, true},
} }
c := newBinFlatChecker() c := newBinFlatChecker()

View File

@ -9,8 +9,8 @@ type binIVFFlatChecker struct {
} }
func (c binIVFFlatChecker) StaticCheck(params map[string]string) error { func (c binIVFFlatChecker) StaticCheck(params map[string]string) error {
if !CheckStrByValues(params, Metric, BinIvfMetrics) { if !CheckStrByValues(params, Metric, BinMetrics) {
return fmt.Errorf("metric type not found or not supported, supported: %v", BinIvfMetrics) return fmt.Errorf("metric type not found or not supported, supported: %v", BinMetrics)
} }
if !CheckIntByRange(params, NLIST, MinNList, MaxNList) { if !CheckIntByRange(params, NLIST, MinNList, MaxNList) {

View File

@ -65,7 +65,6 @@ func Test_binIVFFlatChecker_CheckTrain(t *testing.T) {
IVFM: strconv.Itoa(4), IVFM: strconv.Itoa(4),
NBITS: strconv.Itoa(8), NBITS: strconv.Itoa(8),
} }
p4 := map[string]string{ p4 := map[string]string{
DIM: strconv.Itoa(128), DIM: strconv.Itoa(128),
Metric: metric.HAMMING, Metric: metric.HAMMING,
@ -80,28 +79,6 @@ func Test_binIVFFlatChecker_CheckTrain(t *testing.T) {
IVFM: strconv.Itoa(4), IVFM: strconv.Itoa(4),
NBITS: strconv.Itoa(8), NBITS: strconv.Itoa(8),
} }
p6 := map[string]string{
DIM: strconv.Itoa(128),
Metric: metric.TANIMOTO,
NLIST: strconv.Itoa(100),
IVFM: strconv.Itoa(4),
NBITS: strconv.Itoa(8),
}
p7 := map[string]string{
DIM: strconv.Itoa(128),
Metric: metric.SUBSTRUCTURE,
NLIST: strconv.Itoa(100),
IVFM: strconv.Itoa(4),
NBITS: strconv.Itoa(8),
}
p8 := map[string]string{
DIM: strconv.Itoa(128),
Metric: metric.SUPERSTRUCTURE,
NLIST: strconv.Itoa(100),
IVFM: strconv.Itoa(4),
NBITS: strconv.Itoa(8),
}
cases := []struct { cases := []struct {
params map[string]string params map[string]string
@ -119,10 +96,6 @@ func Test_binIVFFlatChecker_CheckTrain(t *testing.T) {
{p4, true}, {p4, true},
{p5, true}, {p5, true},
{p6, true},
{p7, false},
{p8, false},
} }
c := newBinIVFFlatChecker() c := newBinIVFFlatChecker()

View File

@ -13,8 +13,8 @@ type binaryVectorBaseChecker struct {
} }
func (c binaryVectorBaseChecker) staticCheck(params map[string]string) error { func (c binaryVectorBaseChecker) staticCheck(params map[string]string) error {
if !CheckStrByValues(params, Metric, BinIDMapMetrics) { if !CheckStrByValues(params, Metric, BinMetrics) {
return fmt.Errorf("metric type not found or not supported, supported: %v", BinIDMapMetrics) return fmt.Errorf("metric type not found or not supported, supported: %v", BinMetrics)
} }
return nil return nil

View File

@ -47,9 +47,7 @@ const (
var METRICS = []string{metric.L2, metric.IP, metric.COSINE} // const var METRICS = []string{metric.L2, metric.IP, metric.COSINE} // const
// BinIDMapMetrics is a set of all metric types supported for binary vector. // BinIDMapMetrics is a set of all metric types supported for binary vector.
var BinIDMapMetrics = []string{metric.HAMMING, metric.JACCARD, metric.TANIMOTO, metric.SUBSTRUCTURE, var BinMetrics = []string{metric.HAMMING, metric.JACCARD} // const
metric.SUPERSTRUCTURE} // const
var BinIvfMetrics = []string{metric.HAMMING, metric.JACCARD, metric.TANIMOTO} // const
var HnswMetrics = []string{metric.L2, metric.IP, metric.COSINE, metric.HAMMING, metric.JACCARD} // const var HnswMetrics = []string{metric.L2, metric.IP, metric.COSINE, metric.HAMMING, metric.JACCARD} // const
var supportDimPerSubQuantizer = []int{32, 28, 24, 20, 16, 12, 10, 8, 6, 4, 3, 2, 1} // const var supportDimPerSubQuantizer = []int{32, 28, 24, 20, 16, 12, 10, 8, 6, 4, 3, 2, 1} // const
var supportSubQuantizer = []int{96, 64, 56, 48, 40, 32, 28, 24, 20, 16, 12, 8, 4, 3, 2, 1} // const var supportSubQuantizer = []int{96, 64, 56, 48, 40, 32, 28, 24, 20, 16, 12, 8, 4, 3, 2, 1} // const

View File

@ -37,7 +37,6 @@ func Test_diskannChecker_CheckTrain(t *testing.T) {
DIM: strconv.Itoa(128), DIM: strconv.Itoa(128),
Metric: metric.COSINE, Metric: metric.COSINE,
} }
p4 := map[string]string{ p4 := map[string]string{
DIM: strconv.Itoa(128), DIM: strconv.Itoa(128),
Metric: metric.HAMMING, Metric: metric.HAMMING,
@ -46,18 +45,6 @@ func Test_diskannChecker_CheckTrain(t *testing.T) {
DIM: strconv.Itoa(128), DIM: strconv.Itoa(128),
Metric: metric.JACCARD, Metric: metric.JACCARD,
} }
p6 := map[string]string{
DIM: strconv.Itoa(128),
Metric: metric.TANIMOTO,
}
p7 := map[string]string{
DIM: strconv.Itoa(128),
Metric: metric.SUBSTRUCTURE,
}
p8 := map[string]string{
DIM: strconv.Itoa(128),
Metric: metric.SUPERSTRUCTURE,
}
cases := []struct { cases := []struct {
params map[string]string params map[string]string
@ -72,9 +59,6 @@ func Test_diskannChecker_CheckTrain(t *testing.T) {
{p3, true}, {p3, true},
{p4, false}, {p4, false},
{p5, false}, {p5, false},
{p6, false},
{p7, false},
{p8, false},
} }
c := newDiskannChecker() c := newDiskannChecker()

View File

@ -23,7 +23,6 @@ func Test_flatChecker_CheckTrain(t *testing.T) {
DIM: strconv.Itoa(128), DIM: strconv.Itoa(128),
Metric: metric.COSINE, Metric: metric.COSINE,
} }
p4 := map[string]string{ p4 := map[string]string{
DIM: strconv.Itoa(128), DIM: strconv.Itoa(128),
Metric: metric.HAMMING, Metric: metric.HAMMING,
@ -32,18 +31,7 @@ func Test_flatChecker_CheckTrain(t *testing.T) {
DIM: strconv.Itoa(128), DIM: strconv.Itoa(128),
Metric: metric.JACCARD, Metric: metric.JACCARD,
} }
p6 := map[string]string{
DIM: strconv.Itoa(128),
Metric: metric.TANIMOTO,
}
p7 := map[string]string{
DIM: strconv.Itoa(128),
Metric: metric.SUBSTRUCTURE,
}
p8 := map[string]string{
DIM: strconv.Itoa(128),
Metric: metric.SUPERSTRUCTURE,
}
cases := []struct { cases := []struct {
params map[string]string params map[string]string
errIsNil bool errIsNil bool
@ -53,9 +41,6 @@ func Test_flatChecker_CheckTrain(t *testing.T) {
{p3, true}, {p3, true},
{p4, false}, {p4, false},
{p5, false}, {p5, false},
{p6, false},
{p7, false},
{p8, false},
} }
c := newFlatChecker() c := newFlatChecker()

View File

@ -49,7 +49,6 @@ func Test_hnswChecker_CheckTrain(t *testing.T) {
EFConstruction: strconv.Itoa(200), EFConstruction: strconv.Itoa(200),
Metric: metric.COSINE, Metric: metric.COSINE,
} }
p4 := map[string]string{ p4 := map[string]string{
DIM: strconv.Itoa(128), DIM: strconv.Itoa(128),
HNSWM: strconv.Itoa(16), HNSWM: strconv.Itoa(16),
@ -62,24 +61,6 @@ func Test_hnswChecker_CheckTrain(t *testing.T) {
EFConstruction: strconv.Itoa(200), EFConstruction: strconv.Itoa(200),
Metric: metric.JACCARD, Metric: metric.JACCARD,
} }
p6 := map[string]string{
DIM: strconv.Itoa(128),
HNSWM: strconv.Itoa(16),
EFConstruction: strconv.Itoa(200),
Metric: metric.TANIMOTO,
}
p7 := map[string]string{
DIM: strconv.Itoa(128),
HNSWM: strconv.Itoa(16),
EFConstruction: strconv.Itoa(200),
Metric: metric.SUBSTRUCTURE,
}
p8 := map[string]string{
DIM: strconv.Itoa(128),
HNSWM: strconv.Itoa(16),
EFConstruction: strconv.Itoa(200),
Metric: metric.SUPERSTRUCTURE,
}
cases := []struct { cases := []struct {
params map[string]string params map[string]string
@ -95,9 +76,6 @@ func Test_hnswChecker_CheckTrain(t *testing.T) {
{p3, true}, {p3, true},
{p4, true}, {p4, true},
{p5, true}, {p5, true},
{p6, false},
{p7, false},
{p8, false},
} }
c := newHnswChecker() c := newHnswChecker()

View File

@ -32,7 +32,6 @@ func Test_ivfBaseChecker_CheckTrain(t *testing.T) {
NLIST: strconv.Itoa(1024), NLIST: strconv.Itoa(1024),
Metric: metric.COSINE, Metric: metric.COSINE,
} }
p4 := map[string]string{ p4 := map[string]string{
DIM: strconv.Itoa(128), DIM: strconv.Itoa(128),
NLIST: strconv.Itoa(1024), NLIST: strconv.Itoa(1024),
@ -43,21 +42,6 @@ func Test_ivfBaseChecker_CheckTrain(t *testing.T) {
NLIST: strconv.Itoa(1024), NLIST: strconv.Itoa(1024),
Metric: metric.JACCARD, Metric: metric.JACCARD,
} }
p6 := map[string]string{
DIM: strconv.Itoa(128),
NLIST: strconv.Itoa(1024),
Metric: metric.TANIMOTO,
}
p7 := map[string]string{
DIM: strconv.Itoa(128),
NLIST: strconv.Itoa(1024),
Metric: metric.SUBSTRUCTURE,
}
p8 := map[string]string{
DIM: strconv.Itoa(128),
NLIST: strconv.Itoa(1024),
Metric: metric.SUPERSTRUCTURE,
}
cases := []struct { cases := []struct {
params map[string]string params map[string]string
@ -71,9 +55,6 @@ func Test_ivfBaseChecker_CheckTrain(t *testing.T) {
{p3, true}, {p3, true},
{p4, false}, {p4, false},
{p5, false}, {p5, false},
{p6, false},
{p7, false},
{p8, false},
} }
c := newIVFBaseChecker() c := newIVFBaseChecker()

View File

@ -84,7 +84,6 @@ func Test_ivfPQChecker_CheckTrain(t *testing.T) {
NBITS: strconv.Itoa(8), NBITS: strconv.Itoa(8),
Metric: metric.COSINE, Metric: metric.COSINE,
} }
p4 := map[string]string{ p4 := map[string]string{
DIM: strconv.Itoa(128), DIM: strconv.Itoa(128),
NLIST: strconv.Itoa(1024), NLIST: strconv.Itoa(1024),
@ -99,27 +98,6 @@ func Test_ivfPQChecker_CheckTrain(t *testing.T) {
NBITS: strconv.Itoa(8), NBITS: strconv.Itoa(8),
Metric: metric.JACCARD, Metric: metric.JACCARD,
} }
p6 := map[string]string{
DIM: strconv.Itoa(128),
NLIST: strconv.Itoa(1024),
IVFM: strconv.Itoa(4),
NBITS: strconv.Itoa(8),
Metric: metric.TANIMOTO,
}
p7 := map[string]string{
DIM: strconv.Itoa(128),
NLIST: strconv.Itoa(1024),
IVFM: strconv.Itoa(4),
NBITS: strconv.Itoa(8),
Metric: metric.SUBSTRUCTURE,
}
p8 := map[string]string{
DIM: strconv.Itoa(128),
NLIST: strconv.Itoa(1024),
IVFM: strconv.Itoa(4),
NBITS: strconv.Itoa(8),
Metric: metric.SUPERSTRUCTURE,
}
cases := []struct { cases := []struct {
params map[string]string params map[string]string
@ -142,9 +120,6 @@ func Test_ivfPQChecker_CheckTrain(t *testing.T) {
{p3, true}, {p3, true},
{p4, false}, {p4, false},
{p5, false}, {p5, false},
{p6, false},
{p7, false},
{p8, false},
} }
c := newIVFPQChecker() c := newIVFPQChecker()

View File

@ -46,7 +46,6 @@ func Test_ivfSQChecker_CheckTrain(t *testing.T) {
NBITS: strconv.Itoa(8), NBITS: strconv.Itoa(8),
Metric: metric.COSINE, Metric: metric.COSINE,
} }
p4 := map[string]string{ p4 := map[string]string{
DIM: strconv.Itoa(128), DIM: strconv.Itoa(128),
NLIST: strconv.Itoa(100), NLIST: strconv.Itoa(100),
@ -59,24 +58,6 @@ func Test_ivfSQChecker_CheckTrain(t *testing.T) {
NBITS: strconv.Itoa(8), NBITS: strconv.Itoa(8),
Metric: metric.JACCARD, Metric: metric.JACCARD,
} }
p6 := map[string]string{
DIM: strconv.Itoa(128),
NLIST: strconv.Itoa(100),
NBITS: strconv.Itoa(8),
Metric: metric.TANIMOTO,
}
p7 := map[string]string{
DIM: strconv.Itoa(128),
NLIST: strconv.Itoa(100),
NBITS: strconv.Itoa(8),
Metric: metric.SUBSTRUCTURE,
}
p8 := map[string]string{
DIM: strconv.Itoa(128),
NLIST: strconv.Itoa(100),
NBITS: strconv.Itoa(8),
Metric: metric.SUPERSTRUCTURE,
}
cases := []struct { cases := []struct {
params map[string]string params map[string]string
@ -92,9 +73,6 @@ func Test_ivfSQChecker_CheckTrain(t *testing.T) {
{p3, true}, {p3, true},
{p4, false}, {p4, false},
{p5, false}, {p5, false},
{p6, false},
{p7, false},
{p8, false},
} }
c := newIVFSQChecker() c := newIVFSQChecker()

View File

@ -77,7 +77,6 @@ func Test_raftIVFPQChecker_CheckTrain(t *testing.T) {
NBITS: strconv.Itoa(8), NBITS: strconv.Itoa(8),
Metric: metric.COSINE, Metric: metric.COSINE,
} }
p4 := map[string]string{ p4 := map[string]string{
DIM: strconv.Itoa(128), DIM: strconv.Itoa(128),
NLIST: strconv.Itoa(1024), NLIST: strconv.Itoa(1024),
@ -92,27 +91,6 @@ func Test_raftIVFPQChecker_CheckTrain(t *testing.T) {
NBITS: strconv.Itoa(8), NBITS: strconv.Itoa(8),
Metric: metric.JACCARD, Metric: metric.JACCARD,
} }
p6 := map[string]string{
DIM: strconv.Itoa(128),
NLIST: strconv.Itoa(1024),
IVFM: strconv.Itoa(4),
NBITS: strconv.Itoa(8),
Metric: metric.TANIMOTO,
}
p7 := map[string]string{
DIM: strconv.Itoa(128),
NLIST: strconv.Itoa(1024),
IVFM: strconv.Itoa(4),
NBITS: strconv.Itoa(8),
Metric: metric.SUBSTRUCTURE,
}
p8 := map[string]string{
DIM: strconv.Itoa(128),
NLIST: strconv.Itoa(1024),
IVFM: strconv.Itoa(4),
NBITS: strconv.Itoa(8),
Metric: metric.SUPERSTRUCTURE,
}
cases := []struct { cases := []struct {
params map[string]string params map[string]string
@ -134,9 +112,6 @@ func Test_raftIVFPQChecker_CheckTrain(t *testing.T) {
{p3, true}, {p3, true},
{p4, false}, {p4, false},
{p5, false}, {p5, false},
{p6, false},
{p7, false},
{p8, false},
} }
c := newRaftIVFPQChecker() c := newRaftIVFPQChecker()

View File

@ -30,13 +30,4 @@ const (
// JACCARD represents jaccard distance // JACCARD represents jaccard distance
JACCARD MetricType = "JACCARD" JACCARD MetricType = "JACCARD"
// TANIMOTO represents tanimoto distance
TANIMOTO MetricType = "TANIMOTO"
// SUBSTRUCTURE represents substructure distance
SUBSTRUCTURE MetricType = "SUBSTRUCTURE"
// SUPERSTRUCTURE represents superstructure distance
SUPERSTRUCTURE MetricType = "SUPERSTRUCTURE"
) )

View File

@ -28,12 +28,8 @@ func TestPositivelyRelated(t *testing.T) {
true, true,
}, },
{ {
JACCARD, COSINE,
false, true,
},
{
TANIMOTO,
false,
}, },
{ {
L2, L2,
@ -44,11 +40,7 @@ func TestPositivelyRelated(t *testing.T) {
false, false,
}, },
{ {
SUPERSTRUCTURE, JACCARD,
false,
},
{
SUBSTRUCTURE,
false, false,
}, },
} }

View File

@ -237,7 +237,7 @@ delete_support = ["FLAT", "IVF_FLAT", "IVF_SQ8", "IVF_PQ"]
ivf = ["FLAT", "IVF_FLAT", "IVF_SQ8", "IVF_PQ"] ivf = ["FLAT", "IVF_FLAT", "IVF_SQ8", "IVF_PQ"]
skip_pq = ["IVF_PQ"] skip_pq = ["IVF_PQ"]
float_metrics = ["L2", "IP", "COSINE"] float_metrics = ["L2", "IP", "COSINE"]
binary_metrics = ["JACCARD", "HAMMING", "TANIMOTO", "SUBSTRUCTURE", "SUPERSTRUCTURE"] binary_metrics = ["JACCARD", "HAMMING"]
structure_metrics = ["SUBSTRUCTURE", "SUPERSTRUCTURE"] structure_metrics = ["SUBSTRUCTURE", "SUPERSTRUCTURE"]
all_scalar_data_types = ['int8', 'int16', 'int32', 'int64', 'float', 'double', 'bool', 'varchar'] all_scalar_data_types = ['int8', 'int16', 'int32', 'int64', 'float', 'double', 'bool', 'varchar']

View File

@ -75,7 +75,7 @@ def skip_pq():
def binary_metrics(): def binary_metrics():
return ["JACCARD", "HAMMING", "TANIMOTO", "SUBSTRUCTURE", "SUPERSTRUCTURE"] return ["JACCARD", "HAMMING"]
def structure_metrics(): def structure_metrics():