2020-12-29 18:02:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
## 8. Data Service
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### 8.1 Overview
|
|
|
|
|
2021-01-14 15:12:08 +08:00
|
|
|
<img src="./figs/data_service.png" width=700>
|
2020-12-29 18:02:44 +08:00
|
|
|
|
2021-01-13 11:08:03 +08:00
|
|
|
#### 8.2 Data Service Interface
|
2020-12-29 18:02:44 +08:00
|
|
|
|
|
|
|
```go
|
2021-01-13 11:08:03 +08:00
|
|
|
type DataService interface {
|
2021-04-12 12:45:38 +08:00
|
|
|
Component
|
|
|
|
TimeTickProvider
|
|
|
|
|
|
|
|
RegisterNode(ctx context.Context, req *datapb.RegisterNodeRequest) (*datapb.RegisterNodeResponse, error)
|
|
|
|
Flush(ctx context.Context, req *datapb.FlushRequest) (*commonpb.Status, error)
|
|
|
|
|
|
|
|
AssignSegmentID(ctx context.Context, req *datapb.AssignSegmentIDRequest) (*datapb.AssignSegmentIDResponse, error)
|
|
|
|
ShowSegments(ctx context.Context, req *datapb.ShowSegmentsRequest) (*datapb.ShowSegmentsResponse, error)
|
|
|
|
GetSegmentStates(ctx context.Context, req *datapb.GetSegmentStatesRequest) (*datapb.GetSegmentStatesResponse, error)
|
|
|
|
GetInsertBinlogPaths(ctx context.Context, req *datapb.GetInsertBinlogPathsRequest) (*datapb.GetInsertBinlogPathsResponse, error)
|
|
|
|
GetSegmentInfoChannel(ctx context.Context) (*milvuspb.StringResponse, error)
|
|
|
|
GetInsertChannels(ctx context.Context, req *datapb.GetInsertChannelsRequest) (*internalpb.StringList, error)
|
|
|
|
GetCollectionStatistics(ctx context.Context, req *datapb.GetCollectionStatisticsRequest) (*datapb.GetCollectionStatisticsResponse, error)
|
|
|
|
GetPartitionStatistics(ctx context.Context, req *datapb.GetPartitionStatisticsRequest) (*datapb.GetPartitionStatisticsResponse, error)
|
|
|
|
GetSegmentInfo(ctx context.Context, req *datapb.GetSegmentInfoRequest) (*datapb.GetSegmentInfoResponse, error)
|
2020-12-29 18:02:44 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-15 14:38:36 +08:00
|
|
|
* *MsgBase*
|
2021-01-13 11:08:03 +08:00
|
|
|
|
|
|
|
```go
|
2021-01-15 14:38:36 +08:00
|
|
|
type MsgBase struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
MsgType MsgType
|
|
|
|
MsgID UniqueID
|
|
|
|
Timestamp Timestamp
|
|
|
|
SourceID UniqueID
|
2021-01-13 11:08:03 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-01-11 18:35:54 +08:00
|
|
|
* *RegisterNode*
|
|
|
|
|
|
|
|
```go
|
2021-01-13 11:08:03 +08:00
|
|
|
type RegisterNodeRequest struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
Base *commonpb.MsgBase
|
|
|
|
Address *commonpb.Address
|
2021-01-13 11:08:03 +08:00
|
|
|
}
|
2021-01-11 18:35:54 +08:00
|
|
|
|
2021-01-13 11:08:03 +08:00
|
|
|
type RegisterNodeResponse struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
InitParams *internalpb.InitParams
|
|
|
|
Status *commonpb.Status
|
2021-03-04 10:35:28 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
* *Flush*
|
|
|
|
|
|
|
|
```go
|
|
|
|
type FlushRequest struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
Base *commonpb.MsgBase
|
|
|
|
DbID UniqueID
|
|
|
|
CollectionID UniqueID
|
2021-01-13 11:08:03 +08:00
|
|
|
}
|
2021-01-11 18:35:54 +08:00
|
|
|
```
|
|
|
|
|
2020-12-29 18:02:44 +08:00
|
|
|
* *AssignSegmentID*
|
|
|
|
|
|
|
|
```go
|
2021-04-12 12:45:38 +08:00
|
|
|
type SegmentIDRequest struct {
|
|
|
|
Count uint32
|
|
|
|
ChannelName string
|
|
|
|
CollectionID UniqueID
|
|
|
|
PartitionID UniqueID
|
2020-12-29 18:02:44 +08:00
|
|
|
}
|
|
|
|
|
2021-04-12 12:45:38 +08:00
|
|
|
type AssignSegmentIDRequest struct {
|
|
|
|
NodeID int64
|
|
|
|
PeerRole string
|
|
|
|
SegIDRequests []*SegmentIDRequest
|
2020-12-29 18:02:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type SegIDAssignment struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
SegID UniqueID
|
|
|
|
ChannelName string
|
|
|
|
Count uint32
|
|
|
|
CollectionID UniqueID
|
|
|
|
PartitionID UniqueID
|
|
|
|
ExpireTime uint64
|
|
|
|
Status *commonpb.Status
|
2020-12-29 18:02:44 +08:00
|
|
|
}
|
|
|
|
|
2021-04-12 12:45:38 +08:00
|
|
|
type AssignSegmentIDResponse struct {
|
|
|
|
SegIDAssignments []*SegmentIDAssignment
|
|
|
|
Status *commonpb.Status
|
2020-12-29 18:02:44 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-01-12 18:03:24 +08:00
|
|
|
* *ShowSegments*
|
|
|
|
|
|
|
|
```go
|
2021-04-12 12:45:38 +08:00
|
|
|
type ShowSegmentsRequest struct {
|
|
|
|
Base *commonpb.MsgBase
|
|
|
|
CollectionID UniqueID
|
|
|
|
PartitionID UniqueID
|
|
|
|
DbID UniqueID
|
2021-01-12 18:03:24 +08:00
|
|
|
}
|
|
|
|
|
2021-04-12 12:45:38 +08:00
|
|
|
type ShowSegmentsResponse struct {
|
|
|
|
SegmentIDs []UniqueID
|
|
|
|
Status *commonpb.Status
|
2021-01-12 18:03:24 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* *GetSegmentStates*
|
|
|
|
|
|
|
|
```go
|
2021-04-12 12:45:38 +08:00
|
|
|
type GetSegmentStatesRequest struct {
|
|
|
|
Base *commonpb.MsgBase
|
|
|
|
SegmentID UniqueID
|
2021-01-12 18:03:24 +08:00
|
|
|
}
|
|
|
|
|
2021-04-12 12:45:38 +08:00
|
|
|
type SegmentState int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
SegmentState_SegmentStateNone SegmentState = 0
|
|
|
|
SegmentState_NotExist SegmentState = 1
|
|
|
|
SegmentState_Growing SegmentState = 2
|
|
|
|
SegmentState_Sealed SegmentState = 3
|
|
|
|
SegmentState_Flushed SegmentState = 4
|
|
|
|
)
|
2021-02-03 18:55:00 +08:00
|
|
|
|
2021-03-04 10:35:28 +08:00
|
|
|
type SegmentStateInfo struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
SegmentID UniqueID
|
|
|
|
State commonpb.SegmentState
|
|
|
|
CreateTime uint64
|
|
|
|
SealedTime uint64
|
|
|
|
FlushedTime uint64
|
|
|
|
StartPosition *internalpb.MsgPosition
|
|
|
|
EndPosition *internalpb.MsgPosition
|
|
|
|
Status *commonpb.Status
|
2021-02-03 18:55:00 +08:00
|
|
|
}
|
2021-01-12 18:03:24 +08:00
|
|
|
|
2021-04-12 12:45:38 +08:00
|
|
|
type GetSegmentStatesResponse struct {
|
|
|
|
Status *commonpb.Status
|
|
|
|
States []*SegmentStateInfo
|
2021-02-03 18:55:00 +08:00
|
|
|
}
|
|
|
|
```
|
2021-01-12 18:03:24 +08:00
|
|
|
|
2020-12-29 18:02:44 +08:00
|
|
|
* *GetInsertBinlogPaths*
|
|
|
|
|
|
|
|
```go
|
2021-04-12 12:45:38 +08:00
|
|
|
type GetInsertBinlogPathsRequest struct {
|
|
|
|
Base *commonpb.MsgBase
|
|
|
|
SegmentID UniqueID
|
2020-12-29 18:02:44 +08:00
|
|
|
}
|
|
|
|
|
2021-04-12 12:45:38 +08:00
|
|
|
type GetInsertBinlogPathsResponse struct {
|
|
|
|
FieldIDs []int64
|
|
|
|
Paths []*internalpb.StringList
|
|
|
|
Status *commonpb.Status
|
2020-12-29 18:02:44 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
* *GetInsertChannels*
|
|
|
|
|
|
|
|
```go
|
2021-04-12 12:45:38 +08:00
|
|
|
type GetInsertChannelsRequest struct {
|
|
|
|
Base *commonpb.MsgBase
|
|
|
|
DbID UniqueID
|
|
|
|
CollectionID UniqueID
|
2021-01-15 14:38:36 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-01-20 16:46:58 +08:00
|
|
|
* *GetCollectionStatistics*
|
|
|
|
|
|
|
|
```go
|
2021-04-12 12:45:38 +08:00
|
|
|
type GetCollectionStatisticsRequest struct {
|
|
|
|
Base *commonpb.MsgBase
|
|
|
|
DbID int64
|
|
|
|
CollectionID int64
|
2021-01-20 16:46:58 +08:00
|
|
|
}
|
2021-03-04 10:35:28 +08:00
|
|
|
|
2021-04-12 12:45:38 +08:00
|
|
|
type GetCollectionStatisticsResponse struct {
|
|
|
|
Stats []*commonpb.KeyValuePair
|
|
|
|
Status *commonpb.Status
|
2021-01-20 16:46:58 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
* *GetPartitionStatistics*
|
|
|
|
|
|
|
|
```go
|
2021-04-12 12:45:38 +08:00
|
|
|
type GetPartitionStatisticsRequest struct {
|
|
|
|
Base *commonpb.MsgBase
|
|
|
|
DbID UniqueID
|
|
|
|
CollectionID UniqueID
|
|
|
|
PartitionID UniqueID
|
2021-01-20 16:46:58 +08:00
|
|
|
}
|
2021-03-04 10:35:28 +08:00
|
|
|
|
2021-04-12 12:45:38 +08:00
|
|
|
type GetPartitionStatisticsResponse struct {
|
|
|
|
Stats []*commonpb.KeyValuePair
|
|
|
|
Status *commonpb.Status
|
2021-01-20 16:46:58 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-03-04 10:35:28 +08:00
|
|
|
* *GetSegmentInfo*
|
|
|
|
|
|
|
|
```go
|
2021-04-12 12:45:38 +08:00
|
|
|
type GetSegmentInfoRequest struct{
|
|
|
|
Base *commonpb.MsgBase
|
|
|
|
SegmentIDs []UniqueID
|
2021-03-04 10:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type SegmentInfo struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
SegmentID UniqueID
|
|
|
|
CollectionID UniqueID
|
|
|
|
PartitionID UniqueID
|
|
|
|
InsertChannel string
|
|
|
|
OpenTime Timestamp
|
|
|
|
SealedTime Timestamp
|
|
|
|
FlushedTime Timestamp
|
|
|
|
NumRows int64
|
|
|
|
MemSize int64
|
|
|
|
State SegmentState
|
|
|
|
StartPosition []*internalpb.MsgPosition
|
|
|
|
EndPosition []*internalpb.MsgPosition
|
|
|
|
}
|
|
|
|
|
|
|
|
type GetSegmentInfoResponse struct{
|
|
|
|
Status *commonpb.Status
|
|
|
|
infos []SegmentInfo
|
2021-03-04 10:35:28 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-15 14:38:36 +08:00
|
|
|
|
|
|
|
#### 8.2 Insert Channel
|
|
|
|
|
2021-04-12 12:45:38 +08:00
|
|
|
* *InsertMsg*
|
|
|
|
|
2021-01-15 14:38:36 +08:00
|
|
|
```go
|
|
|
|
type InsertRequest struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
Base *commonpb.MsgBase
|
|
|
|
DbName string
|
|
|
|
CollectionName string
|
|
|
|
PartitionName string
|
|
|
|
DbID UniqueID
|
|
|
|
CollectionID UniqueID
|
|
|
|
PartitionID UniqueID
|
|
|
|
SegmentID UniqueID
|
|
|
|
ChannelID string
|
|
|
|
Timestamps []uint64
|
|
|
|
RowIDs []int64
|
|
|
|
RowData []*commonpb.Blob
|
|
|
|
}
|
|
|
|
|
|
|
|
type InsertMsg struct {
|
|
|
|
BaseMsg
|
|
|
|
InsertRequest
|
2021-01-15 14:02:12 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-13 11:08:03 +08:00
|
|
|
#### 8.2 Data Node Interface
|
2021-01-11 18:35:54 +08:00
|
|
|
|
|
|
|
```go
|
|
|
|
type DataNode interface {
|
2021-04-12 12:45:38 +08:00
|
|
|
Component
|
|
|
|
|
|
|
|
WatchDmChannels(ctx context.Context, req *datapb.WatchDmChannelsRequest) (*commonpb.Status, error)
|
|
|
|
FlushSegments(ctx context.Context, req *datapb.FlushSegmentsRequest) (*commonpb.Status, error)
|
2021-02-04 19:34:35 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-01-13 11:08:03 +08:00
|
|
|
* *WatchDmChannels*
|
|
|
|
|
|
|
|
```go
|
|
|
|
type WatchDmChannelRequest struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
Base *commonpb.MsgBase
|
|
|
|
ChannelNames []string
|
2021-01-13 11:08:03 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
* *FlushSegments*
|
|
|
|
|
|
|
|
```go
|
2021-04-12 12:45:38 +08:00
|
|
|
type FlushSegmentsRequest struct {
|
|
|
|
Base *commonpb.MsgBase
|
|
|
|
DbID UniqueID
|
|
|
|
CollectionID UniqueID
|
|
|
|
SegmentIDs []int64
|
2021-01-11 18:35:54 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-03-04 10:35:28 +08:00
|
|
|
|
|
|
|
#### 8.2 SegmentStatistics Update Channel
|
|
|
|
|
2021-04-12 12:45:38 +08:00
|
|
|
* *SegmentStatisticsMsg*
|
2021-01-16 15:47:33 +08:00
|
|
|
|
|
|
|
```go
|
|
|
|
type SegmentStatisticsUpdates struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
SegmentID UniqueID
|
|
|
|
MemorySize int64
|
|
|
|
NumRows int64
|
|
|
|
CreateTime uint64
|
|
|
|
EndTime uint64
|
|
|
|
StartPosition *internalpb.MsgPosition
|
|
|
|
EndPosition *internalpb.MsgPosition
|
|
|
|
}
|
|
|
|
|
|
|
|
type SegmentStatistics struct {
|
|
|
|
Base *commonpb.MsgBase
|
|
|
|
SegStats []*SegmentStatisticsUpdates
|
|
|
|
}
|
|
|
|
|
|
|
|
type SegmentStatisticsMsg struct {
|
|
|
|
BaseMsg
|
|
|
|
SegmentStatistics
|
2021-01-16 15:47:33 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|