query_node.go 15.3 KB
Newer Older
1
package querynode
B
bigsheeper 已提交
2

3 4
/*

5
#cgo CFLAGS: -I${SRCDIR}/../core/output/include
6

G
GuoRentong 已提交
7
#cgo LDFLAGS: -L${SRCDIR}/../core/output/lib -lmilvus_segcore -Wl,-rpath=${SRCDIR}/../core/output/lib
8

F
FluorineDog 已提交
9 10
#include "segcore/collection_c.h"
#include "segcore/segment_c.h"
11 12

*/
B
bigsheeper 已提交
13
import "C"
14

B
bigsheeper 已提交
15
import (
16
	"context"
17
	"fmt"
C
cai.zhang 已提交
18
	"sync/atomic"
19

S
sunby 已提交
20 21
	"errors"

B
bigsheeper 已提交
22 23 24
	"go.uber.org/zap"

	"github.com/zilliztech/milvus-distributed/internal/log"
G
groot 已提交
25
	"github.com/zilliztech/milvus-distributed/internal/msgstream"
X
Xiangyu Wang 已提交
26
	"github.com/zilliztech/milvus-distributed/internal/msgstream/pulsarms"
G
groot 已提交
27
	"github.com/zilliztech/milvus-distributed/internal/msgstream/rmqms"
28
	"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
C
cai.zhang 已提交
29
	"github.com/zilliztech/milvus-distributed/internal/proto/internalpb2"
30
	queryPb "github.com/zilliztech/milvus-distributed/internal/proto/querypb"
31
	"github.com/zilliztech/milvus-distributed/internal/util/typeutil"
B
bigsheeper 已提交
32 33
)

34 35 36
type Node interface {
	typeutil.Component

G
godchen 已提交
37 38 39 40 41 42 43 44
	AddQueryChannel(ctx context.Context, in *queryPb.AddQueryChannelsRequest) (*commonpb.Status, error)
	RemoveQueryChannel(ctx context.Context, in *queryPb.RemoveQueryChannelsRequest) (*commonpb.Status, error)
	WatchDmChannels(ctx context.Context, in *queryPb.WatchDmChannelsRequest) (*commonpb.Status, error)
	LoadSegments(ctx context.Context, in *queryPb.LoadSegmentRequest) (*commonpb.Status, error)
	ReleaseCollection(ctx context.Context, in *queryPb.ReleaseCollectionRequest) (*commonpb.Status, error)
	ReleasePartitions(ctx context.Context, in *queryPb.ReleasePartitionRequest) (*commonpb.Status, error)
	ReleaseSegments(ctx context.Context, in *queryPb.ReleaseSegmentRequest) (*commonpb.Status, error)
	GetSegmentInfo(ctx context.Context, in *queryPb.SegmentInfoRequest) (*queryPb.SegmentInfoResponse, error)
45 46
}

X
xige-16 已提交
47
type QueryService = typeutil.QueryServiceInterface
48

B
bigsheeper 已提交
49
type QueryNode struct {
50 51
	typeutil.Service

X
XuanYang-cn 已提交
52
	queryNodeLoopCtx    context.Context
53
	queryNodeLoopCancel context.CancelFunc
54

55
	QueryNodeID UniqueID
C
cai.zhang 已提交
56
	stateCode   atomic.Value
B
bigsheeper 已提交
57

X
XuanYang-cn 已提交
58
	replica collectionReplica
B
bigsheeper 已提交
59

60
	// internal services
61 62 63 64 65
	dataSyncService *dataSyncService
	metaService     *metaService
	searchService   *searchService
	loadService     *loadService
	statsService    *statsService
66

67
	// clients
B
bigsheeper 已提交
68 69 70 71
	masterClient MasterServiceInterface
	queryClient  QueryServiceInterface
	indexClient  IndexServiceInterface
	dataClient   DataServiceInterface
G
groot 已提交
72 73

	msFactory msgstream.Factory
B
bigsheeper 已提交
74
}
75

76
func NewQueryNode(ctx context.Context, queryNodeID UniqueID, factory msgstream.Factory) *QueryNode {
X
XuanYang-cn 已提交
77
	ctx1, cancel := context.WithCancel(ctx)
C
cai.zhang 已提交
78
	node := &QueryNode{
79 80 81 82 83 84 85 86
		queryNodeLoopCtx:    ctx1,
		queryNodeLoopCancel: cancel,
		QueryNodeID:         queryNodeID,

		dataSyncService: nil,
		metaService:     nil,
		searchService:   nil,
		statsService:    nil,
G
groot 已提交
87 88

		msFactory: factory,
89 90
	}

B
bigsheeper 已提交
91
	node.replica = newCollectionReplicaImpl()
92
	node.UpdateStateCode(internalpb2.StateCode_ABNORMAL)
C
cai.zhang 已提交
93 94
	return node
}
G
godchen 已提交
95

G
groot 已提交
96
func NewQueryNodeWithoutID(ctx context.Context, factory msgstream.Factory) *QueryNode {
97 98 99 100 101 102 103 104 105
	ctx1, cancel := context.WithCancel(ctx)
	node := &QueryNode{
		queryNodeLoopCtx:    ctx1,
		queryNodeLoopCancel: cancel,

		dataSyncService: nil,
		metaService:     nil,
		searchService:   nil,
		statsService:    nil,
G
groot 已提交
106 107

		msFactory: factory,
108 109
	}

B
bigsheeper 已提交
110
	node.replica = newCollectionReplicaImpl()
111
	node.UpdateStateCode(internalpb2.StateCode_ABNORMAL)
112

113
	return node
B
bigsheeper 已提交
114 115
}

N
neza2017 已提交
116
func (node *QueryNode) Init() error {
G
godchen 已提交
117
	ctx := context.Background()
X
xige-16 已提交
118
	registerReq := &queryPb.RegisterNodeRequest{
119 120 121 122
		Base: &commonpb.MsgBase{
			MsgType:  commonpb.MsgType_kNone,
			SourceID: Params.QueryNodeID,
		},
C
cai.zhang 已提交
123 124 125 126 127
		Address: &commonpb.Address{
			Ip:   Params.QueryNodeIP,
			Port: Params.QueryNodePort,
		},
	}
128

G
godchen 已提交
129
	resp, err := node.queryClient.RegisterNode(ctx, registerReq)
C
cai.zhang 已提交
130 131 132
	if err != nil {
		panic(err)
	}
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
	if resp.Status.ErrorCode != commonpb.ErrorCode_SUCCESS {
		panic(resp.Status.Reason)
	}

	for _, kv := range resp.InitParams.StartParams {
		switch kv.Key {
		case "StatsChannelName":
			Params.StatsChannelName = kv.Value
		case "TimeTickChannelName":
			Params.QueryTimeTickChannelName = kv.Value
		case "QueryChannelName":
			Params.SearchChannelNames = append(Params.SearchChannelNames, kv.Value)
		case "QueryResultChannelName":
			Params.SearchResultChannelNames = append(Params.SearchResultChannelNames, kv.Value)
		default:
S
sunby 已提交
148
			return fmt.Errorf("Invalid key: %v", kv.Key)
149
		}
C
cai.zhang 已提交
150 151
	}

B
bigsheeper 已提交
152
	log.Debug("", zap.Int64("QueryNodeID", Params.QueryNodeID))
C
cai.zhang 已提交
153

154
	if node.masterClient == nil {
B
bigsheeper 已提交
155
		log.Error("null master service detected")
156 157
	}

158
	if node.indexClient == nil {
B
bigsheeper 已提交
159
		log.Error("null index service detected")
160 161 162
	}

	if node.dataClient == nil {
B
bigsheeper 已提交
163
		log.Error("null data service detected")
164 165
	}

166 167 168 169
	return nil
}

func (node *QueryNode) Start() error {
G
groot 已提交
170 171 172 173 174 175 176 177 178 179
	var err error
	m := map[string]interface{}{
		"PulsarAddress":  Params.PulsarAddress,
		"ReceiveBufSize": 1024,
		"PulsarBufSize":  1024}
	err = node.msFactory.SetParams(m)
	if err != nil {
		return err
	}

X
XuanYang-cn 已提交
180
	// init services and manager
G
groot 已提交
181 182
	node.dataSyncService = newDataSyncService(node.queryNodeLoopCtx, node.replica, node.msFactory)
	node.searchService = newSearchService(node.queryNodeLoopCtx, node.replica, node.msFactory)
B
bigsheeper 已提交
183
	//node.metaService = newMetaService(node.queryNodeLoopCtx, node.replica)
G
groot 已提交
184

185
	node.loadService = newLoadService(node.queryNodeLoopCtx, node.masterClient, node.dataClient, node.indexClient, node.replica, node.dataSyncService.dmStream)
G
groot 已提交
186
	node.statsService = newStatsService(node.queryNodeLoopCtx, node.replica, node.loadService.segLoader.indexLoader.fieldStatsChan, node.msFactory)
B
bigsheeper 已提交
187

X
XuanYang-cn 已提交
188
	// start services
189
	go node.dataSyncService.start()
N
neza2017 已提交
190
	go node.searchService.start()
B
bigsheeper 已提交
191
	//go node.metaService.start()
192
	go node.loadService.start()
X
XuanYang-cn 已提交
193
	go node.statsService.start()
194
	node.UpdateStateCode(internalpb2.StateCode_HEALTHY)
N
neza2017 已提交
195
	return nil
B
bigsheeper 已提交
196
}
B
bigsheeper 已提交
197

N
neza2017 已提交
198
func (node *QueryNode) Stop() error {
199
	node.UpdateStateCode(internalpb2.StateCode_ABNORMAL)
X
XuanYang-cn 已提交
200 201
	node.queryNodeLoopCancel()

B
bigsheeper 已提交
202
	// free collectionReplica
X
XuanYang-cn 已提交
203
	node.replica.freeAll()
B
bigsheeper 已提交
204 205 206

	// close services
	if node.dataSyncService != nil {
X
XuanYang-cn 已提交
207
		node.dataSyncService.close()
B
bigsheeper 已提交
208 209
	}
	if node.searchService != nil {
X
XuanYang-cn 已提交
210
		node.searchService.close()
B
bigsheeper 已提交
211
	}
212 213
	if node.loadService != nil {
		node.loadService.close()
B
bigsheeper 已提交
214
	}
B
bigsheeper 已提交
215
	if node.statsService != nil {
X
XuanYang-cn 已提交
216
		node.statsService.close()
B
bigsheeper 已提交
217
	}
N
neza2017 已提交
218
	return nil
X
XuanYang-cn 已提交
219 220
}

221 222 223 224
func (node *QueryNode) UpdateStateCode(code internalpb2.StateCode) {
	node.stateCode.Store(code)
}

B
bigsheeper 已提交
225 226 227 228 229 230 231 232
func (node *QueryNode) SetMasterService(master MasterServiceInterface) error {
	if master == nil {
		return errors.New("null master service interface")
	}
	node.masterClient = master
	return nil
}

233 234
func (node *QueryNode) SetQueryService(query QueryServiceInterface) error {
	if query == nil {
B
bigsheeper 已提交
235
		return errors.New("null query service interface")
236 237 238 239 240
	}
	node.queryClient = query
	return nil
}

241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
func (node *QueryNode) SetIndexService(index IndexServiceInterface) error {
	if index == nil {
		return errors.New("null index service interface")
	}
	node.indexClient = index
	return nil
}

func (node *QueryNode) SetDataService(data DataServiceInterface) error {
	if data == nil {
		return errors.New("null data service interface")
	}
	node.dataClient = data
	return nil
}

C
cai.zhang 已提交
257
func (node *QueryNode) GetComponentStates() (*internalpb2.ComponentStates, error) {
258 259 260 261 262
	stats := &internalpb2.ComponentStates{
		Status: &commonpb.Status{
			ErrorCode: commonpb.ErrorCode_SUCCESS,
		},
	}
C
cai.zhang 已提交
263 264
	code, ok := node.stateCode.Load().(internalpb2.StateCode)
	if !ok {
265 266 267 268 269 270
		errMsg := "unexpected error in type assertion"
		stats.Status = &commonpb.Status{
			ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
			Reason:    errMsg,
		}
		return stats, errors.New(errMsg)
C
cai.zhang 已提交
271 272 273
	}
	info := &internalpb2.ComponentInfo{
		NodeID:    Params.QueryNodeID,
X
XuanYang-cn 已提交
274
		Role:      typeutil.QueryNodeRole,
C
cai.zhang 已提交
275 276
		StateCode: code,
	}
277
	stats.State = info
C
cai.zhang 已提交
278 279 280 281
	return stats, nil
}

func (node *QueryNode) GetTimeTickChannel() (string, error) {
N
neza2017 已提交
282
	return Params.QueryTimeTickChannelName, nil
C
cai.zhang 已提交
283 284 285 286 287 288
}

func (node *QueryNode) GetStatisticsChannel() (string, error) {
	return Params.StatsChannelName, nil
}

X
XuanYang-cn 已提交
289 290 291 292 293 294 295 296 297 298 299 300 301 302
func (node *QueryNode) AddQueryChannel(in *queryPb.AddQueryChannelsRequest) (*commonpb.Status, error) {
	if node.searchService == nil || node.searchService.searchMsgStream == nil {
		errMsg := "null search service or null search message stream"
		status := &commonpb.Status{
			ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
			Reason:    errMsg,
		}

		return status, errors.New(errMsg)
	}

	// add request channel
	consumeChannels := []string{in.RequestChannelID}
	consumeSubName := Params.MsgChannelSubName
X
xige-16 已提交
303
	node.searchService.searchMsgStream.AsConsumer(consumeChannels, consumeSubName)
X
XuanYang-cn 已提交
304 305 306

	// add result channel
	producerChannels := []string{in.ResultChannelID}
X
xige-16 已提交
307
	node.searchService.searchResultMsgStream.AsProducer(producerChannels)
X
XuanYang-cn 已提交
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325

	status := &commonpb.Status{
		ErrorCode: commonpb.ErrorCode_SUCCESS,
	}
	return status, nil
}

func (node *QueryNode) RemoveQueryChannel(in *queryPb.RemoveQueryChannelsRequest) (*commonpb.Status, error) {
	if node.searchService == nil || node.searchService.searchMsgStream == nil {
		errMsg := "null search service or null search result message stream"
		status := &commonpb.Status{
			ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
			Reason:    errMsg,
		}

		return status, errors.New(errMsg)
	}

X
Xiangyu Wang 已提交
326
	searchStream, ok := node.searchService.searchMsgStream.(*pulsarms.PulsarMsgStream)
X
XuanYang-cn 已提交
327 328 329 330 331 332 333 334 335 336
	if !ok {
		errMsg := "type assertion failed for search message stream"
		status := &commonpb.Status{
			ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
			Reason:    errMsg,
		}

		return status, errors.New(errMsg)
	}

X
Xiangyu Wang 已提交
337
	resultStream, ok := node.searchService.searchResultMsgStream.(*pulsarms.PulsarMsgStream)
X
XuanYang-cn 已提交
338 339 340 341 342 343 344 345 346 347 348 349 350 351
	if !ok {
		errMsg := "type assertion failed for search result message stream"
		status := &commonpb.Status{
			ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
			Reason:    errMsg,
		}

		return status, errors.New(errMsg)
	}

	// remove request channel
	consumeChannels := []string{in.RequestChannelID}
	consumeSubName := Params.MsgChannelSubName
	// TODO: searchStream.RemovePulsarConsumers(producerChannels)
Z
zhenshan.cao 已提交
352
	searchStream.AsConsumer(consumeChannels, consumeSubName)
X
XuanYang-cn 已提交
353 354 355 356

	// remove result channel
	producerChannels := []string{in.ResultChannelID}
	// TODO: resultStream.RemovePulsarProducer(producerChannels)
Z
zhenshan.cao 已提交
357
	resultStream.AsProducer(producerChannels)
X
XuanYang-cn 已提交
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375

	status := &commonpb.Status{
		ErrorCode: commonpb.ErrorCode_SUCCESS,
	}
	return status, nil
}

func (node *QueryNode) WatchDmChannels(in *queryPb.WatchDmChannelsRequest) (*commonpb.Status, error) {
	if node.dataSyncService == nil || node.dataSyncService.dmStream == nil {
		errMsg := "null data sync service or null data manipulation stream"
		status := &commonpb.Status{
			ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
			Reason:    errMsg,
		}

		return status, errors.New(errMsg)
	}

G
groot 已提交
376 377 378 379 380
	switch t := node.dataSyncService.dmStream.(type) {
	case *pulsarms.PulsarTtMsgStream:
	case *rmqms.RmqTtMsgStream:
	default:
		_ = t
X
XuanYang-cn 已提交
381 382 383 384 385 386 387 388 389 390 391 392
		errMsg := "type assertion failed for dm message stream"
		status := &commonpb.Status{
			ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
			Reason:    errMsg,
		}

		return status, errors.New(errMsg)
	}

	// add request channel
	consumeChannels := in.ChannelIDs
	consumeSubName := Params.MsgChannelSubName
G
groot 已提交
393
	node.dataSyncService.dmStream.AsConsumer(consumeChannels, consumeSubName)
X
XuanYang-cn 已提交
394 395 396 397 398 399 400 401 402

	status := &commonpb.Status{
		ErrorCode: commonpb.ErrorCode_SUCCESS,
	}
	return status, nil
}

func (node *QueryNode) LoadSegments(in *queryPb.LoadSegmentRequest) (*commonpb.Status, error) {
	// TODO: support db
Z
zhenshan.cao 已提交
403
	collectionID := in.CollectionID
C
cai.zhang 已提交
404 405
	partitionID := in.PartitionID
	segmentIDs := in.SegmentIDs
X
XuanYang-cn 已提交
406
	fieldIDs := in.FieldIDs
407
	schema := in.Schema
408

B
bigsheeper 已提交
409
	log.Debug("query node load segment", zap.String("loadSegmentRequest", fmt.Sprintln(in)))
X
xige-16 已提交
410 411 412 413

	status := &commonpb.Status{
		ErrorCode: commonpb.ErrorCode_SUCCESS,
	}
414 415 416 417 418
	hasCollection := node.replica.hasCollection(collectionID)
	hasPartition := node.replica.hasPartition(partitionID)
	if !hasCollection {
		err := node.replica.addCollection(collectionID, schema)
		if err != nil {
X
xige-16 已提交
419 420
			status.ErrorCode = commonpb.ErrorCode_UNEXPECTED_ERROR
			status.Reason = err.Error()
421 422 423 424 425 426
			return status, err
		}
	}
	if !hasPartition {
		err := node.replica.addPartition(collectionID, partitionID)
		if err != nil {
X
xige-16 已提交
427 428
			status.ErrorCode = commonpb.ErrorCode_UNEXPECTED_ERROR
			status.Reason = err.Error()
429 430 431
			return status, err
		}
	}
432
	err := node.replica.enablePartition(partitionID)
C
cai.zhang 已提交
433
	if err != nil {
X
xige-16 已提交
434 435 436 437 438 439 440 441 442 443 444 445 446
		status.ErrorCode = commonpb.ErrorCode_UNEXPECTED_ERROR
		status.Reason = err.Error()
		return status, err
	}

	if len(segmentIDs) == 0 {
		return status, nil
	}

	if len(in.SegmentIDs) != len(in.SegmentStates) {
		err := errors.New("len(segmentIDs) should equal to len(segmentStates)")
		status.ErrorCode = commonpb.ErrorCode_UNEXPECTED_ERROR
		status.Reason = err.Error()
C
cai.zhang 已提交
447 448 449
		return status, err
	}

450
	// segments are ordered before LoadSegments calling
X
xige-16 已提交
451
	var position *internalpb2.MsgPosition = nil
452
	for i, state := range in.SegmentStates {
X
xige-16 已提交
453 454 455 456 457
		thisPosition := state.StartPosition
		if state.State <= commonpb.SegmentState_SegmentGrowing {
			if position == nil {
				position = &internalpb2.MsgPosition{
					ChannelName: thisPosition.ChannelName,
458
				}
C
cai.zhang 已提交
459
			}
460 461
			segmentIDs = segmentIDs[:i]
			break
C
cai.zhang 已提交
462
		}
X
xige-16 已提交
463
		position = state.StartPosition
464 465
	}

X
xige-16 已提交
466
	err = node.dataSyncService.seekSegment(position)
C
cai.zhang 已提交
467 468 469 470
	if err != nil {
		status := &commonpb.Status{
			ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
			Reason:    err.Error(),
Z
zhenshan.cao 已提交
471
		}
C
cai.zhang 已提交
472
		return status, err
Z
zhenshan.cao 已提交
473
	}
X
xige-16 已提交
474 475 476 477 478 479 480 481

	err = node.loadService.loadSegment(collectionID, partitionID, segmentIDs, fieldIDs)
	if err != nil {
		status.ErrorCode = commonpb.ErrorCode_UNEXPECTED_ERROR
		status.Reason = err.Error()
		return status, err
	}
	return status, nil
C
cai.zhang 已提交
482 483
}

B
bigsheeper 已提交
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502
func (node *QueryNode) ReleaseCollection(in *queryPb.ReleaseCollectionRequest) (*commonpb.Status, error) {
	err := node.replica.removeCollection(in.CollectionID)
	if err != nil {
		status := &commonpb.Status{
			ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
			Reason:    err.Error(),
		}
		return status, err
	}

	return &commonpb.Status{
		ErrorCode: commonpb.ErrorCode_SUCCESS,
	}, nil
}

func (node *QueryNode) ReleasePartitions(in *queryPb.ReleasePartitionRequest) (*commonpb.Status, error) {
	status := &commonpb.Status{
		ErrorCode: commonpb.ErrorCode_SUCCESS,
	}
C
cai.zhang 已提交
503
	for _, id := range in.PartitionIDs {
B
bigsheeper 已提交
504
		err := node.loadService.segLoader.replica.removePartition(id)
C
cai.zhang 已提交
505
		if err != nil {
B
bigsheeper 已提交
506 507 508
			// not return, try to release all partitions
			status.ErrorCode = commonpb.ErrorCode_UNEXPECTED_ERROR
			status.Reason = err.Error()
C
cai.zhang 已提交
509 510
		}
	}
B
bigsheeper 已提交
511 512
	return status, nil
}
C
cai.zhang 已提交
513

B
bigsheeper 已提交
514 515 516 517
func (node *QueryNode) ReleaseSegments(in *queryPb.ReleaseSegmentRequest) (*commonpb.Status, error) {
	status := &commonpb.Status{
		ErrorCode: commonpb.ErrorCode_SUCCESS,
	}
C
cai.zhang 已提交
518
	for _, id := range in.SegmentIDs {
B
bigsheeper 已提交
519 520 521 522 523
		err2 := node.loadService.segLoader.replica.removeSegment(id)
		if err2 != nil {
			// not return, try to release all segments
			status.ErrorCode = commonpb.ErrorCode_UNEXPECTED_ERROR
			status.Reason = err2.Error()
X
XuanYang-cn 已提交
524 525
		}
	}
B
bigsheeper 已提交
526
	return status, nil
X
XuanYang-cn 已提交
527
}
B
bigsheeper 已提交
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553

func (node *QueryNode) GetSegmentInfo(in *queryPb.SegmentInfoRequest) (*queryPb.SegmentInfoResponse, error) {
	infos := make([]*queryPb.SegmentInfo, 0)
	for _, id := range in.SegmentIDs {
		segment, err := node.replica.getSegmentByID(id)
		if err != nil {
			continue
		}
		info := &queryPb.SegmentInfo{
			SegmentID:    segment.ID(),
			CollectionID: segment.collectionID,
			PartitionID:  segment.partitionID,
			MemSize:      segment.getMemSize(),
			NumRows:      segment.getRowCount(),
			IndexName:    segment.getIndexName(),
			IndexID:      segment.getIndexID(),
		}
		infos = append(infos, info)
	}
	return &queryPb.SegmentInfoResponse{
		Status: &commonpb.Status{
			ErrorCode: commonpb.ErrorCode_SUCCESS,
		},
		Infos: infos,
	}, nil
}