milvus/docs/developer_guides/chap07_query_service.md
zhenshan.cao 04e2062750 Update proto
Signed-off-by: zhenshan.cao <zhenshan.cao@zilliz.com>
2021-01-14 20:30:27 +08:00

5.0 KiB

8. Query Service

8.1 Overview

8.2 Query Service Interface

type QueryService interface {
  Service
  
  RegisterNode(req RegisterNodeRequest) (RegisterNodeResponse, error)
  
  ShowCollections(req ShowCollectionRequest) (ShowCollectionResponse, error)
  LoadCollection(req LoadCollectionRequest) error
  ReleaseCollection(req ReleaseCollectionRequest) error
  
  ShowPartitions(req ShowPartitionRequest) (ShowPartitionResponse, error)
  GetPartitionStates(req PartitionStatesRequest) (PartitionStatesResponse, error)
  LoadPartitions(req LoadPartitonRequest) error
  ReleasePartitions(req ReleasePartitionRequest) error
  
  CreateQueryChannel() (CreateQueryChannelResponse, error)
}
  • RequestBase
type RequestBase struct {
  MsgType MsgType
  ReqID	UniqueID
  Timestamp Timestamp
  RequestorID UniqueID
}
  • RegisterNode
type RegisterNodeRequest struct {
  RequestBase
  Address string
  Port int64
}

type RegisterNodeResponse struct {
  //InitParams
}
  • ShowCollections
type ShowCollectionRequest struct {
  RequestBase
  DbID UniqueID
}

type ShowCollectionResponse struct {
  CollectionIDs []UniqueID
}
  • LoadCollection
type LoadCollectionRequest struct {
  RequestBase
  DbID UniqueID
  CollectionID UniqueID
}
  • ReleaseCollection
type ReleaseCollectionRequest struct {
  RequestBase
  DbID UniqueID
  CollectionID UniqueID
}
  • ShowPartitions
type ShowPartitionRequest struct {
  RequestBase
  DbID UniqueID
  CollectionID UniqueID
}

type ShowPartitionResponse struct {
  PartitionIDs []UniqueID
}
  • GetPartitionStates
type PartitionState = int

const (
  NOT_EXIST PartitionState = 0
  NOT_PRESENT PartitionState = 1
  ON_DISK PartitionState = 2
  PARTIAL_IN_MEMORY PartitionState = 3
	IN_MEMORY PartitionState = 4
  PARTIAL_IN_GPU PartitionState = 5
  IN_GPU PartitionState = 6
)

type PartitionStatesRequest struct {
  RequestBase
  DbID UniqueID
  CollectionID UniqueID
  PartitionIDs []UniqueID
}

type PartitionStates struct {
  PartitionID UniqueID
  State PartitionState
}

type PartitionStatesResponse struct {
  States []PartitionStates
}
  • LoadPartitions
type LoadPartitonRequest struct {
  RequestBase
  DbID UniqueID
  CollectionID UniqueID
  PartitionIDs []UniqueID
}
  • ReleasePartitions
type ReleasePartitionRequest struct {
  RequestBase
  DbID UniqueID
  CollectionID UniqueID
  PartitionIDs []UniqueID
}
  • CreateQueryChannel
type CreateQueryChannelResponse struct {
  RequestChannelName string
  ResultChannelName string
}

8.2 Query Node Interface

type QueryNode interface {
  Service
  
  AddQueryChannel(req AddQueryChannelRequest) error
  RemoveQueryChannel(req RemoveQueryChannelRequest) error
  WatchDmChannels(req WatchDmChannelRequest) error
  //SetTimeTickChannel(channelName string) error
  //SetStatsChannel(channelName string) error
  
  LoadSegments(req LoadSegmentRequest) error
  ReleaseSegments(req ReleaseSegmentRequest) error
  //DescribeParition(req DescribeParitionRequest) (PartitionDescriptions, error)
}
  • AddQueryChannel
type AddQueryChannelRequest struct {
  RequestBase
  RequestChannelName string
  ResultChannelName string
}
  • RemoveQueryChannel
type RemoveQueryChannelRequest struct {
  RequestChannelName string
  ResultChannelName string
}
  • WatchDmChannels
type WatchDmChannelRequest struct {
  InsertChannelNames []string
}
  • LoadSegments
type LoadSegmentRequest struct {
  RequestBase
  DbID UniqueID
  CollectionID UniqueID
  PartitionID UniqueID
  SegmentIDs []UniqueID
  FieldIDs []int64
}
  • ReleaseSegments
type ReleaseSegmentRequest struct {
  RequestBase
  DbID UniqueID
  CollectionID UniqueID
  PartitionID UniqueID
  SegmentIDs []UniqueID
}

8.2 Collection Replica

collectionReplica contains a in-memory local copy of persistent collections. In common cases, the system has multiple query nodes. Data of a collection will be distributed across all the available query nodes, and each query node's collectionReplica will maintain its own share (only part of the collection). Every replica tracks a value called tSafe which is the maximum timestamp that the replica is up-to-date.

8.1.1 Collection
type Collection struct {
  Name string
  Id uint64
  Fields map[string]FieldMeta
  SegmentsId []uint64
  
  cCollectionSchema C.CCollectionSchema
}
8.1.2 Field Meta
type FieldMeta struct {
  Name string
  Id uint64
  IsPrimaryKey bool
  TypeParams map[string]string
  IndexParams map[string]string
}
8.1.3 Segment
type Segment struct {
  Id uint64
  ParitionName string
  CollectionId uint64
  OpenTime Timestamp
  CloseTime Timestamp
  NumRows uint64
  
  cSegment C.CSegmentBase
}

8.3 Data Sync Service

type dataSyncService struct {
	ctx context.Context
	pulsarURL string
	fg *flowgraph.TimeTickedFlowGraph
	msgStream *msgstream.PulsarMsgStream
	dataReplica Replica
}