Don't build BIN_FLAT index really (#20309)

Signed-off-by: cai.zhang <cai.zhang@zilliz.com>

Signed-off-by: cai.zhang <cai.zhang@zilliz.com>
pull/20013/head
cai.zhang 2022-11-03 18:23:37 +08:00 committed by GitHub
parent e7103310b8
commit 6c4658db22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 8 deletions

View File

@ -24,6 +24,7 @@ const (
CreateIndexTaskName = "CreateIndexTask"
flatIndex = "FLAT"
binFlatIndex = "BIN_FLAT"
diskAnnIndex = "DISKANN"
invalidIndex = "invalid"

View File

@ -26,8 +26,6 @@ import (
"time"
"github.com/golang/protobuf/proto"
clientv3 "go.etcd.io/etcd/client/v3"
"go.uber.org/zap"
"github.com/milvus-io/milvus-proto/go-api/commonpb"
@ -51,7 +49,6 @@ type flushedSegmentWatcher struct {
internalNotify chan struct{}
etcdRevision int64
watchChan clientv3.WatchChan
meta *metaTable
builder *indexBuilder

View File

@ -153,7 +153,6 @@ func Test_flushedSegmentWatcher_internalRun(t *testing.T) {
internalTaskMutex: sync.RWMutex{},
internalNotify: make(chan struct{}, 1),
etcdRevision: 0,
watchChan: nil,
meta: nil,
builder: nil,
ic: &IndexCoord{
@ -493,7 +492,6 @@ func Test_flushSegmentWatcher_prepare_error(t *testing.T) {
internalTaskMutex: sync.RWMutex{},
internalNotify: make(chan struct{}, 1),
etcdRevision: 0,
watchChan: nil,
meta: nil,
builder: nil,
ic: &IndexCoord{
@ -527,7 +525,6 @@ func Test_flushSegmentWatcher_prepare_error(t *testing.T) {
internalTaskMutex: sync.RWMutex{},
internalNotify: make(chan struct{}, 1),
etcdRevision: 0,
watchChan: nil,
meta: nil,
builder: nil,
ic: &IndexCoord{
@ -640,7 +637,6 @@ func Test_flushSegmentWatcher_constructTask_error(t *testing.T) {
internalTaskMutex: sync.RWMutex{},
internalNotify: make(chan struct{}, 1),
etcdRevision: 0,
watchChan: nil,
meta: meta,
builder: nil,
ic: &IndexCoord{

View File

@ -213,7 +213,7 @@ func (ib *indexBuilder) process(buildID UniqueID) bool {
return true
}
indexParams := ib.meta.GetIndexParams(meta.CollectionID, meta.IndexID)
if getIndexType(indexParams) == flatIndex || meta.NumRows < Params.IndexCoordCfg.MinSegmentNumRowsToEnableIndex {
if isFlatIndex(getIndexType(indexParams)) || meta.NumRows < Params.IndexCoordCfg.MinSegmentNumRowsToEnableIndex {
log.Ctx(ib.ctx).Debug("segment does not need index really", zap.Int64("buildID", buildID),
zap.Int64("segID", meta.SegmentID), zap.Int64("num rows", meta.NumRows))
if err := ib.meta.FinishTask(&indexpb.IndexTaskInfo{

View File

@ -82,3 +82,7 @@ func getIndexType(indexParams []*commonpb.KeyValuePair) string {
}
return invalidIndex
}
func isFlatIndex(indexType string) bool {
return indexType == flatIndex || indexType == binFlatIndex
}

View File

@ -89,3 +89,9 @@ func Test_parseKey(t *testing.T) {
_, err2 := parseBuildIDFromFilePath(key2)
assert.Error(t, err2)
}
func Test_isFlatIndex(t *testing.T) {
assert.True(t, isFlatIndex(flatIndex))
assert.True(t, isFlatIndex(binFlatIndex))
assert.False(t, isFlatIndex(diskAnnIndex))
}