2020-08-25 15:45:19 +08:00
|
|
|
package reader
|
|
|
|
|
2020-09-02 10:38:08 +08:00
|
|
|
/*
|
|
|
|
|
2020-10-23 18:01:24 +08:00
|
|
|
#cgo CFLAGS: -I${SRCDIR}/../core/output/include
|
2020-09-02 10:38:08 +08:00
|
|
|
|
2020-10-31 15:11:47 +08:00
|
|
|
#cgo LDFLAGS: -L${SRCDIR}/../core/output/lib -lmilvus_segcore -Wl,-rpath=${SRCDIR}/../core/output/lib
|
2020-09-02 10:38:08 +08:00
|
|
|
|
|
|
|
#include "collection_c.h"
|
|
|
|
#include "segment_c.h"
|
|
|
|
|
|
|
|
*/
|
2020-08-25 15:45:19 +08:00
|
|
|
import "C"
|
2020-09-02 10:38:08 +08:00
|
|
|
|
2020-08-25 15:45:19 +08:00
|
|
|
import (
|
2020-10-15 21:31:50 +08:00
|
|
|
"context"
|
2020-08-25 15:45:19 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type QueryNode struct {
|
2020-10-15 21:31:50 +08:00
|
|
|
ctx context.Context
|
|
|
|
|
2020-11-05 10:52:50 +08:00
|
|
|
QueryNodeID uint64
|
|
|
|
pulsarURL string
|
2020-08-25 15:45:19 +08:00
|
|
|
|
2020-11-09 16:27:11 +08:00
|
|
|
tSafe Timestamp
|
2020-09-07 17:01:46 +08:00
|
|
|
|
2020-11-09 16:27:11 +08:00
|
|
|
container *ColSegContainer
|
2020-08-25 15:45:19 +08:00
|
|
|
|
2020-11-09 16:27:11 +08:00
|
|
|
dataSyncService *dataSyncService
|
|
|
|
metaService *metaService
|
|
|
|
searchService *searchService
|
|
|
|
statsService *statsService
|
2020-11-05 10:52:50 +08:00
|
|
|
}
|
2020-09-07 17:01:46 +08:00
|
|
|
|
2020-11-05 10:52:50 +08:00
|
|
|
func NewQueryNode(ctx context.Context, queryNodeID uint64, pulsarURL string) *QueryNode {
|
|
|
|
segmentsMap := make(map[int64]*Segment)
|
2020-11-09 16:27:11 +08:00
|
|
|
collections := make([]*Collection, 0)
|
2020-09-23 17:38:15 +08:00
|
|
|
|
2020-09-15 17:41:05 +08:00
|
|
|
return &QueryNode{
|
2020-11-05 10:52:50 +08:00
|
|
|
ctx: ctx,
|
2020-09-15 17:41:05 +08:00
|
|
|
|
2020-11-05 10:52:50 +08:00
|
|
|
QueryNodeID: queryNodeID,
|
|
|
|
pulsarURL: pulsarURL,
|
2020-09-15 17:41:05 +08:00
|
|
|
|
2020-11-09 16:27:11 +08:00
|
|
|
tSafe: 0,
|
2020-09-15 17:41:05 +08:00
|
|
|
|
2020-11-09 16:27:11 +08:00
|
|
|
container: &ColSegContainer{
|
|
|
|
collections: collections,
|
|
|
|
segments: segmentsMap,
|
|
|
|
},
|
2020-09-15 17:41:05 +08:00
|
|
|
|
2020-11-09 16:27:11 +08:00
|
|
|
dataSyncService: nil,
|
|
|
|
metaService: nil,
|
|
|
|
searchService: nil,
|
|
|
|
statsService: nil,
|
2020-09-15 15:53:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-05 10:52:50 +08:00
|
|
|
func (node *QueryNode) Start() {
|
2020-11-09 16:27:11 +08:00
|
|
|
node.dataSyncService = newDataSyncService(node.ctx, node, node.pulsarURL)
|
|
|
|
node.searchService = newSearchService(node.ctx, node.container, node.pulsarURL)
|
|
|
|
node.metaService = newMetaService(node.ctx, node.container)
|
|
|
|
node.statsService = newStatsService(node.ctx, node.container, node.pulsarURL)
|
2020-09-15 15:53:10 +08:00
|
|
|
|
2020-11-09 16:27:11 +08:00
|
|
|
go node.dataSyncService.start()
|
2020-11-05 10:52:50 +08:00
|
|
|
go node.searchService.start()
|
|
|
|
go node.metaService.start()
|
2020-11-09 16:27:11 +08:00
|
|
|
node.statsService.start()
|
2020-11-05 10:52:50 +08:00
|
|
|
}
|
2020-09-15 15:53:10 +08:00
|
|
|
|
2020-11-05 10:52:50 +08:00
|
|
|
func (node *QueryNode) Close() {
|
|
|
|
// TODO: close services
|
2020-09-14 11:26:35 +08:00
|
|
|
}
|