Skip to content

Commit

Permalink
revert config
Browse files Browse the repository at this point in the history
Signed-off-by: xianliang.li <[email protected]>
  • Loading branch information
foxspy committed Oct 12, 2024
1 parent 59f9bcf commit e8bde11
Show file tree
Hide file tree
Showing 25 changed files with 144 additions and 164 deletions.
1 change: 1 addition & 0 deletions client/index/disk_ann.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func NewDiskANNIndex(metricType MetricType) Index {
return &diskANNIndex{
baseIndex: baseIndex{
metricType: metricType,
indexType: DISKANN,
},
}
}
2 changes: 2 additions & 0 deletions client/index/flat.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func NewFlatIndex(metricType MetricType) Index {
return flatIndex{
baseIndex: baseIndex{
metricType: metricType,
indexType: Flat,
},
}
}
Expand All @@ -54,6 +55,7 @@ func NewBinFlatIndex(metricType MetricType) Index {
return binFlatIndex{
baseIndex: baseIndex{
metricType: metricType,
indexType: BinFlat,
},
}
}
4 changes: 2 additions & 2 deletions internal/core/src/index/ScalarIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ class ScalarIndex : public IndexBase {

virtual bool
IsMmapSupported() const {
return index_type_ == milvus::index::BITMAP_INDEX_TYPE ||
index_type_ == milvus::index::HYBRID_INDEX_TYPE;
return index_type_ == milvus::index::BITMAP_INDEX_TYPE ||
index_type_ == milvus::index::HYBRID_INDEX_TYPE;
}

virtual int64_t
Expand Down
3 changes: 2 additions & 1 deletion internal/core/src/index/VectorIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ class VectorIndex : public IndexBase {

virtual bool
IsMmapSupported() const {
return knowhere::IndexFactory::Instance().FeatureCheck(index_type_, knowhere::feature::MMAP);
return knowhere::IndexFactory::Instance().FeatureCheck(
index_type_, knowhere::feature::MMAP);
}

knowhere::Json
Expand Down
41 changes: 32 additions & 9 deletions internal/core/src/segcore/vector_index_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@
#include "pb/index_cgo_msg.pb.h"

CStatus
ValidateIndexParams(const char* index_type, enum CDataType data_type, const uint8_t* serialized_index_params, const uint64_t length) {
ValidateIndexParams(const char* index_type,
enum CDataType data_type,
const uint8_t* serialized_index_params,
const uint64_t length) {
try {
auto index_params =
std::make_unique<milvus::proto::indexcgo::IndexParams>();
auto res = index_params->ParseFromArray(serialized_index_params, length);
std::make_unique<milvus::proto::indexcgo::IndexParams>();
auto res =
index_params->ParseFromArray(serialized_index_params, length);
AssertInfo(res, "Unmarshall index params failed");

knowhere::Json json;
Expand All @@ -40,15 +44,35 @@ ValidateIndexParams(const char* index_type, enum CDataType data_type, const uint
knowhere::Status status;
std::string error_msg;
if (dataType == milvus::DataType::VECTOR_BINARY) {
status = knowhere::CheckConfig<knowhere::bin1>(index_type, knowhere::Version::GetCurrentVersion().VersionNumber(), json, knowhere::PARAM_TYPE::TRAIN, error_msg);
status = knowhere::IndexStaticFaced<knowhere::bin1>::ConfigCheck(
index_type,
knowhere::Version::GetCurrentVersion().VersionNumber(),
json,
error_msg);
} else if (dataType == milvus::DataType::VECTOR_FLOAT) {
status = knowhere::CheckConfig<knowhere::fp32>(index_type, knowhere::Version::GetCurrentVersion().VersionNumber(), json, knowhere::PARAM_TYPE::TRAIN, error_msg);
status = knowhere::IndexStaticFaced<knowhere::fp32>::ConfigCheck(
index_type,
knowhere::Version::GetCurrentVersion().VersionNumber(),
json,
error_msg);
} else if (dataType == milvus::DataType::VECTOR_BFLOAT16) {
status = knowhere::CheckConfig<knowhere::bf16>(index_type, knowhere::Version::GetCurrentVersion().VersionNumber(), json, knowhere::PARAM_TYPE::TRAIN, error_msg);
status = knowhere::IndexStaticFaced<knowhere::bf16>::ConfigCheck(
index_type,
knowhere::Version::GetCurrentVersion().VersionNumber(),
json,
error_msg);
} else if (dataType == milvus::DataType::VECTOR_FLOAT16) {
status = knowhere::CheckConfig<knowhere::fp16>(index_type, knowhere::Version::GetCurrentVersion().VersionNumber(), json, knowhere::PARAM_TYPE::TRAIN, error_msg);
status = knowhere::IndexStaticFaced<knowhere::fp16>::ConfigCheck(
index_type,
knowhere::Version::GetCurrentVersion().VersionNumber(),
json,
error_msg);
} else if (dataType == milvus::DataType::VECTOR_SPARSE_FLOAT) {
status = knowhere::CheckConfig<knowhere::fp32>(index_type, knowhere::Version::GetCurrentVersion().VersionNumber(), json, knowhere::PARAM_TYPE::TRAIN, error_msg);
status = knowhere::IndexStaticFaced<knowhere::fp32>::ConfigCheck(
index_type,
knowhere::Version::GetCurrentVersion().VersionNumber(),
json,
error_msg);
} else {
status = knowhere::Status::invalid_args;
}
Expand Down Expand Up @@ -87,4 +111,3 @@ GetIndexFeatures(void* index_key_list, uint64_t* index_feature_list) {
idx++;
}
}

6 changes: 4 additions & 2 deletions internal/core/src/segcore/vector_index_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ extern "C" {
#include "common/type_c.h"

CStatus
ValidateIndexParams(const char* index_type, enum CDataType data_type, const uint8_t* index_params, const uint64_t length);
ValidateIndexParams(const char* index_type,
enum CDataType data_type,
const uint8_t* index_params,
const uint64_t length);

int
GetIndexListSize();

void
GetIndexFeatures(void* index_key_list, uint64_t* index_feature_list);


#ifdef __cplusplus
}
#endif
2 changes: 1 addition & 1 deletion internal/core/thirdparty/knowhere/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# Update KNOWHERE_VERSION for the first occurrence
milvus_add_pkg_config("knowhere")
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES "")
set( KNOWHERE_VERSION add_vector_index_mgr )
set( KNOWHERE_VERSION add_vector_index_mgr_bak )
set( GIT_REPOSITORY "https://github.com/foxspy/knowhere.git")
message(STATUS "Knowhere repo: ${GIT_REPOSITORY}")
message(STATUS "Knowhere version: ${KNOWHERE_VERSION}")
Expand Down
3 changes: 1 addition & 2 deletions internal/datacoord/compaction_task_clustering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import (
"testing"
"time"

"github.com/milvus-io/milvus/pkg/util/metautil"

"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/suite"
"go.uber.org/atomic"
Expand All @@ -41,6 +39,7 @@ import (
"github.com/milvus-io/milvus/internal/storage"
"github.com/milvus-io/milvus/pkg/common"
"github.com/milvus-io/milvus/pkg/util/merr"
"github.com/milvus-io/milvus/pkg/util/metautil"
)

func TestClusteringCompactionTaskSuite(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions internal/datacoord/import_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
package datacoord

import (
"github.com/milvus-io/milvus/pkg/util/funcutil"
"github.com/milvus-io/milvus/pkg/util/paramtable"
"google.golang.org/protobuf/proto"

"github.com/milvus-io/milvus/internal/proto/datapb"
"github.com/milvus-io/milvus/pkg/util/funcutil"
"github.com/milvus-io/milvus/pkg/util/paramtable"
"github.com/milvus-io/milvus/pkg/util/timerecord"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/datacoord/index_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import (
"github.com/milvus-io/milvus/internal/metastore"
"github.com/milvus-io/milvus/internal/metastore/model"
"github.com/milvus-io/milvus/internal/proto/indexpb"
"github.com/milvus-io/milvus/internal/util/indexparamcheck"
"github.com/milvus-io/milvus/internal/proto/workerpb"
"github.com/milvus-io/milvus/internal/util/indexparamcheck"
"github.com/milvus-io/milvus/pkg/common"
"github.com/milvus-io/milvus/pkg/log"
"github.com/milvus-io/milvus/pkg/metrics"
Expand Down
3 changes: 3 additions & 0 deletions internal/util/hookutil/mock_hook.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build test
// +build test

/*
* Licensed to the LF AI & Data foundation under one
* or more contributor license agreements. See the NOTICE file
Expand Down
2 changes: 1 addition & 1 deletion internal/util/indexparamcheck/bin_flat_checker_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package indexparamcheck

import (
"github.com/milvus-io/milvus/pkg/common"
"strconv"
"testing"

"github.com/stretchr/testify/assert"

"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
"github.com/milvus-io/milvus/pkg/common"
"github.com/milvus-io/milvus/pkg/util/metric"
)

Expand Down
8 changes: 5 additions & 3 deletions internal/util/indexparamcheck/bin_ivf_flat_checker_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package indexparamcheck

import (
"github.com/milvus-io/milvus/pkg/common"
"strconv"
"testing"

Expand Down Expand Up @@ -115,8 +116,9 @@ func Test_binIVFFlatChecker_CheckTrain(t *testing.T) {
{p7, false},
}

c, _ := GetIndexCheckerMgrInstance().GetChecker("BINIVFFLAT")
c, _ := GetIndexCheckerMgrInstance().GetChecker("BIN_IVF_FLAT")
for _, test := range cases {
test.params[common.IndexTypeKey] = "BIN_IVF_FLAT"
err := c.CheckTrain(schemapb.DataType_BinaryVector, test.params)
if test.errIsNil {
assert.NoError(t, err)
Expand Down Expand Up @@ -185,10 +187,10 @@ func Test_binIVFFlatChecker_CheckValidDataType(t *testing.T) {
},
}

c, _ := GetIndexCheckerMgrInstance().GetChecker("BINIVFFLAT")
c, _ := GetIndexCheckerMgrInstance().GetChecker("BIN_IVF_FLAT")
for _, test := range cases {
fieldSchema := &schemapb.FieldSchema{DataType: test.dType}
err := c.CheckValidDataType("BINIVFFLAT", fieldSchema)
err := c.CheckValidDataType("BIN_IVF_FLAT", fieldSchema)
if test.errIsNil {
assert.NoError(t, err)
} else {
Expand Down
2 changes: 1 addition & 1 deletion internal/util/indexparamcheck/cagra_checker_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package indexparamcheck

import (
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
"strconv"
"testing"

"github.com/stretchr/testify/assert"

"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
"github.com/milvus-io/milvus/pkg/util/metric"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/util/indexparamcheck/ivf_sq_checker_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package indexparamcheck

import (
"github.com/milvus-io/milvus/pkg/common"
"strconv"
"testing"

"github.com/stretchr/testify/assert"

"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
"github.com/milvus-io/milvus/pkg/common"
"github.com/milvus-io/milvus/pkg/util/metric"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package indexparamcheck

import (
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
"strconv"
"testing"

"github.com/stretchr/testify/assert"

"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
"github.com/milvus-io/milvus/pkg/util/metric"
)

Expand Down
3 changes: 2 additions & 1 deletion internal/util/indexparamcheck/scalar_index_checker_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package indexparamcheck

import (
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
"testing"

"github.com/stretchr/testify/assert"

"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
)

func TestCheckIndexValid(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions internal/util/indexparamcheck/vector_index_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func HandleCStatus(status *C.CStatus) error {
errorMsg := C.GoString(status.error_msg)
defer C.free(unsafe.Pointer(status.error_msg))

return fmt.Errorf("%s", string(errorMsg))
return fmt.Errorf("%s", errorMsg)
}

func (c vecIndexChecker) StaticCheck(dataType schemapb.DataType, params map[string]string) error {
Expand Down Expand Up @@ -79,7 +79,7 @@ func (c vecIndexChecker) CheckTrain(dataType schemapb.DataType, params map[strin

func (c vecIndexChecker) CheckValidDataType(indexType IndexType, field *schemapb.FieldSchema) error {
if !typeutil.IsVectorType(field.GetDataType()) {
return fmt.Errorf("index %s only support vector data type", indexType)
return fmt.Errorf("index %s only supports vector data type", indexType)
}
if !GetVecIndexMgrInstance().IsDataTypeSupport(indexType, field.GetDataType()) {
return fmt.Errorf("index %s do not support data type: %s", indexType, schemapb.DataType_name[int32(field.GetDataType())])
Expand Down
3 changes: 1 addition & 2 deletions internal/util/indexparamcheck/vector_index_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,8 @@ func (mgr *VecIndexMgrImpl) IsDataTypeSupport(indexType IndexType, dataType sche
return mgr.IsFlat16Support(indexType)
} else if dataType == schemapb.DataType_SparseFloatVector {
return mgr.IsSparseFloat32Support(indexType)
} else {
return false
}
return false
}

func (mgr *VecIndexMgrImpl) IsFlatVecIndex(indexType IndexType) bool {
Expand Down
Loading

0 comments on commit e8bde11

Please sign in to comment.