2021-10-03 17:44:25 +08:00
|
|
|
## 9. Data Service
|
2020-12-29 18:02:44 +08:00
|
|
|
|
2021-10-03 17:44:25 +08:00
|
|
|
#### 9.1 Overview
|
2020-12-29 18:02:44 +08:00
|
|
|
|
2021-06-21 19:22:15 +08:00
|
|
|
<img src="./figs/data_coord.png" width=700>
|
2020-12-29 18:02:44 +08:00
|
|
|
|
2021-10-03 17:44:25 +08:00
|
|
|
#### 9.2 Data Service Interface
|
2020-12-29 18:02:44 +08:00
|
|
|
|
|
|
|
```go
|
2021-06-21 16:02:11 +08:00
|
|
|
type DataCoord interface {
|
2021-04-12 12:45:38 +08:00
|
|
|
Component
|
|
|
|
TimeTickProvider
|
|
|
|
|
2021-09-08 17:12:11 +08:00
|
|
|
Flush(ctx context.Context, req *datapb.FlushRequest) (*datapb.FlushResponse, error)
|
2021-04-12 12:45:38 +08:00
|
|
|
|
|
|
|
AssignSegmentID(ctx context.Context, req *datapb.AssignSegmentIDRequest) (*datapb.AssignSegmentIDResponse, 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)
|
|
|
|
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)
|
2021-06-21 16:02:11 +08:00
|
|
|
GetRecoveryInfo(ctx context.Context, req *datapb.GetRecoveryInfoRequest) (*datapb.GetRecoveryInfoResponse, error)
|
|
|
|
SaveBinlogPaths(ctx context.Context, req *datapb.SaveBinlogPathsRequest) (*commonpb.Status, error)
|
2021-09-08 17:12:11 +08:00
|
|
|
GetFlushedSegments(ctx context.Context, req *datapb.GetFlushedSegmentsRequest) (*datapb.GetFlushedSegmentsResponse, error)
|
|
|
|
|
|
|
|
GetMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error)
|
2020-12-29 18:02:44 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-10-11 21:25:47 +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-10-11 21:25:47 +08:00
|
|
|
- _Flush_
|
2021-03-04 10:35:28 +08:00
|
|
|
|
|
|
|
```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
|
|
|
```
|
|
|
|
|
2021-10-11 21:25:47 +08:00
|
|
|
- _AssignSegmentID_
|
2020-12-29 18:02:44 +08:00
|
|
|
|
|
|
|
```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 {
|
2021-10-11 21:25:47 +08:00
|
|
|
NodeID int64
|
|
|
|
PeerRole string
|
|
|
|
SegmentIDRequests []*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-10-11 21:25:47 +08:00
|
|
|
- _GetSegmentStates_
|
2021-01-12 18:03:24 +08:00
|
|
|
|
|
|
|
```go
|
2021-04-12 12:45:38 +08:00
|
|
|
type GetSegmentStatesRequest struct {
|
2021-10-11 21:25:47 +08:00
|
|
|
Base *commonpb.MsgBase
|
|
|
|
SegmentIDs []int64
|
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-06-21 16:02:11 +08:00
|
|
|
SegmentState_Flushing SegmentState = 5
|
2021-04-12 12:45:38 +08:00
|
|
|
)
|
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
|
|
|
|
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
|
|
|
|
2021-10-11 21:25:47 +08:00
|
|
|
- _GetInsertBinlogPaths_
|
2020-12-29 18:02:44 +08:00
|
|
|
|
|
|
|
```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
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-10-11 21:25:47 +08:00
|
|
|
- _GetCollectionStatistics_
|
2021-01-20 16:46:58 +08:00
|
|
|
|
|
|
|
```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
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-10-11 21:25:47 +08:00
|
|
|
- _GetPartitionStatistics_
|
2021-01-20 16:46:58 +08:00
|
|
|
|
|
|
|
```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-10-11 21:25:47 +08:00
|
|
|
- _GetSegmentInfo_
|
2021-03-04 10:35:28 +08:00
|
|
|
|
|
|
|
```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-10-11 21:25:47 +08:00
|
|
|
ID int64
|
|
|
|
CollectionID int64
|
|
|
|
PartitionID int64
|
|
|
|
InsertChannel string
|
|
|
|
NumOfRows int64
|
|
|
|
State commonpb.SegmentState
|
|
|
|
DmlPosition *internalpb.MsgPosition
|
|
|
|
MaxRowNum int64
|
|
|
|
LastExpireTime uint64
|
|
|
|
StartPosition *internalpb.MsgPosition
|
2021-04-12 12:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type GetSegmentInfoResponse struct{
|
|
|
|
Status *commonpb.Status
|
|
|
|
infos []SegmentInfo
|
2021-03-04 10:35:28 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-10-11 21:25:47 +08:00
|
|
|
- _GetRecoveryInfo_
|
2021-06-21 16:02:11 +08:00
|
|
|
|
|
|
|
```go
|
|
|
|
type GetRecoveryInfoRequest struct {
|
2021-10-11 21:25:47 +08:00
|
|
|
Base *commonpb.MsgBase
|
|
|
|
CollectionID int64
|
|
|
|
PartitionID int64
|
2021-06-21 16:02:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type VchannelInfo struct {
|
2021-10-11 21:25:47 +08:00
|
|
|
CollectionID int64
|
|
|
|
ChannelName string
|
|
|
|
SeekPosition *internalpb.MsgPosition
|
|
|
|
UnflushedSegments []*SegmentInfo
|
|
|
|
FlushedSegments []int64
|
2021-06-21 16:02:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type SegmentBinlogs struct {
|
2021-10-11 21:25:47 +08:00
|
|
|
SegmentID int64
|
|
|
|
FieldBinlogs []*FieldBinlog
|
2021-06-21 16:02:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type GetRecoveryInfoResponse struct {
|
2021-10-11 21:25:47 +08:00
|
|
|
Status *commonpb.Status
|
|
|
|
Channels []*VchannelInfo
|
|
|
|
Binlogs []*SegmentBinlogs
|
2021-06-21 16:02:11 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-10-11 21:25:47 +08:00
|
|
|
- _SaveBinlogPaths_
|
|
|
|
|
2021-06-21 16:02:11 +08:00
|
|
|
```go
|
|
|
|
type SegmentStartPosition struct {
|
2021-10-11 21:25:47 +08:00
|
|
|
StartPosition *internalpb.MsgPosition
|
|
|
|
SegmentID int64
|
2021-06-21 16:02:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type SaveBinlogPathsRequest struct {
|
2021-10-11 21:25:47 +08:00
|
|
|
Base *commonpb.MsgBase
|
|
|
|
SegmentID int64
|
|
|
|
CollectionID int64
|
|
|
|
Field2BinlogPaths []*ID2PathList
|
|
|
|
CheckPoints []*CheckPoint
|
|
|
|
StartPositions []*SegmentStartPosition
|
|
|
|
Flushed bool
|
2021-06-21 16:02:11 +08:00
|
|
|
}
|
|
|
|
```
|
2021-03-04 10:35:28 +08:00
|
|
|
|
2021-10-03 17:44:25 +08:00
|
|
|
#### 9.3 Insert Channel
|
2021-01-15 14:38:36 +08:00
|
|
|
|
2021-10-11 21:25:47 +08:00
|
|
|
- _InsertMsg_
|
2021-04-12 12:45:38 +08:00
|
|
|
|
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-10-03 17:44:25 +08:00
|
|
|
#### 9.4 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-10-11 21:25:47 +08:00
|
|
|
- _WatchDmChannels_
|
2021-01-13 11:08:03 +08:00
|
|
|
|
|
|
|
```go
|
|
|
|
type WatchDmChannelRequest struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
Base *commonpb.MsgBase
|
2021-06-21 18:32:12 +08:00
|
|
|
Vchannels []*VchannelInfo
|
2021-01-13 11:08:03 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-10-11 21:25:47 +08:00
|
|
|
- _FlushSegments_
|
2021-01-13 11:08:03 +08:00
|
|
|
|
|
|
|
```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-10-03 17:44:25 +08:00
|
|
|
#### 9.5 SegmentStatistics Update Channel
|
2021-03-04 10:35:28 +08:00
|
|
|
|
2021-10-11 21:25:47 +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
|
|
|
}
|
2021-06-21 18:32:12 +08:00
|
|
|
|
|
|
|
```
|
2021-10-11 21:25:47 +08:00
|
|
|
|
2021-10-03 17:44:25 +08:00
|
|
|
#### 9.6 DataNode Time Tick Channel
|
2021-06-21 18:32:12 +08:00
|
|
|
|
2021-10-11 21:25:47 +08:00
|
|
|
- _DataNode Tt Msg_
|
2021-06-21 18:32:12 +08:00
|
|
|
|
|
|
|
```go
|
|
|
|
message DataNodeTtMsg {
|
|
|
|
Base *commonpb.MsgBase
|
|
|
|
ChannelName string
|
|
|
|
Timestamp uint64
|
|
|
|
}
|
2021-01-16 15:47:33 +08:00
|
|
|
```
|