milvus/docs/developer_guides/chap07_query_service.md
GuoRentong dd6c4bfb75 Update doc:interface definitions related to LoadCollection
Signed-off-by: GuoRentong <rentong.guo@zilliz.com>
2021-01-18 10:09:17 +08:00

5.3 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)
}
  • MsgBase
type MsgBase struct {
  MsgType MsgType
  MsgID	UniqueID
  Timestamp Timestamp
  SourceID UniqueID
}
  • RegisterNode
type RegisterNodeRequest struct {
  MsgBase
  Address string
  Port int64
}

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

type ShowCollectionResponse struct {
  CollectionIDs []UniqueID
}
  • LoadCollection
type LoadCollectionRequest struct {
  MsgBase
  DbID UniqueID
  CollectionID UniqueID
}
  • ReleaseCollection
type ReleaseCollectionRequest struct {
  MsgBase
  DbID UniqueID
  CollectionID UniqueID
}
  • ShowPartitions
type ShowPartitionRequest struct {
  MsgBase
  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 {
  MsgBase
  DbID UniqueID
  CollectionID UniqueID
  PartitionIDs []UniqueID
}

type PartitionStates struct {
  PartitionID UniqueID
  State PartitionState
}

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

8.2 Query Channel

type SearchRequest struct {
  RequestBase
  DbName string
  CollectionName string
  PartitionNames []string
  DbID UniqueID
  CollectionID UniqueID
  PartitionIDs []UniqueID
  Dsl string
  PlaceholderGroup []byte
}

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 {
  MsgBase
  RequestChannelName string
  ResultChannelName string
}
  • RemoveQueryChannel
type RemoveQueryChannelRequest struct {
  RequestChannelName string
  ResultChannelName string
}
  • WatchDmChannels
type WatchDmChannelRequest struct {
  InsertChannelNames []string
  StartSegment UniqueID
  //FieldIDs []int64
}
  • LoadSegments
type LoadSegmentRequest struct {
  MsgBase
  DbID UniqueID
  CollectionID UniqueID
  PartitionID UniqueID
  SegmentIDs []UniqueID
  //FieldIDs []int64
}
  • ReleaseSegments
type ReleaseSegmentRequest struct {
  MsgBase
  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
}