2021-09-24 16:14:12 +08:00
|
|
|
## 3. Index Service
|
2020-12-27 09:05:24 +08:00
|
|
|
|
2021-09-24 16:14:12 +08:00
|
|
|
#### 3.1 Overview
|
2020-12-27 09:05:24 +08:00
|
|
|
|
2021-06-21 19:22:15 +08:00
|
|
|
<img src="./figs/index_coord.png" width=700>
|
2020-12-27 09:05:24 +08:00
|
|
|
|
2021-09-24 16:14:12 +08:00
|
|
|
#### 3.2 Index Service Interface
|
2020-12-27 09:05:24 +08:00
|
|
|
|
2020-12-29 18:02:44 +08:00
|
|
|
```go
|
2021-06-23 16:14:08 +08:00
|
|
|
type IndexCoord interface {
|
2021-09-24 16:14:12 +08:00
|
|
|
Component
|
2021-04-12 12:45:38 +08:00
|
|
|
TimeTickProvider
|
|
|
|
|
2021-11-02 21:30:19 +08:00
|
|
|
// BuildIndex receives request from RootCoordinator to build an index.
|
2021-04-12 12:45:38 +08:00
|
|
|
BuildIndex(ctx context.Context, req *indexpb.BuildIndexRequest) (*indexpb.BuildIndexResponse, error)
|
2021-11-04 11:04:26 +08:00
|
|
|
// DropIndex deletes indexes based on IndexID. One IndexID corresponds to the index of an entire column. A column is
|
|
|
|
// divided into many segments, and each segment corresponds to an IndexBuildID. IndexCoord uses IndexBuildID to record
|
|
|
|
// index tasks. Therefore, when DropIndex is called, delete all tasks corresponding to IndexBuildID corresponding to IndexID.
|
2021-04-12 12:45:38 +08:00
|
|
|
DropIndex(ctx context.Context, req *indexpb.DropIndexRequest) (*commonpb.Status, error)
|
2021-11-05 13:20:27 +08:00
|
|
|
// GetIndexStates gets the index states of the IndexBuildIDs in the request from RootCoordinator.
|
2021-09-08 17:16:04 +08:00
|
|
|
GetIndexStates(ctx context.Context, req *indexpb.GetIndexStatesRequest) (*indexpb.GetIndexStatesResponse, error)
|
|
|
|
GetIndexFilePaths(ctx context.Context, req *indexpb.GetIndexFilePathsRequest) (*indexpb.GetIndexFilePathsResponse, error)
|
|
|
|
GetMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error)
|
2020-12-29 18:02:44 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-10-20 19:29:40 +08:00
|
|
|
- _RegisterNode_
|
2021-01-13 11:08:03 +08:00
|
|
|
|
|
|
|
```go
|
2021-03-04 10:35:28 +08:00
|
|
|
type MsgBase struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
MsgType MsgType
|
|
|
|
MsgID UniqueID
|
|
|
|
Timestamp uint64
|
|
|
|
SourceID UniqueID
|
2021-01-13 11:08:03 +08:00
|
|
|
}
|
|
|
|
|
2021-03-04 10:35:28 +08:00
|
|
|
type Address struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
Ip string
|
|
|
|
Port int64
|
2021-01-13 11:08:03 +08:00
|
|
|
}
|
|
|
|
|
2021-03-04 10:35:28 +08:00
|
|
|
type RegisterNodeRequest struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
Base *commonpb.MsgBase
|
|
|
|
Address *commonpb.Address
|
2021-03-04 10:35:28 +08:00
|
|
|
}
|
2020-12-29 18:02:44 +08:00
|
|
|
|
2021-03-04 10:35:28 +08:00
|
|
|
type InitParams struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
NodeID UniqueID
|
|
|
|
StartParams []*commonpb.KeyValuePair
|
2020-12-29 18:02:44 +08:00
|
|
|
}
|
|
|
|
|
2021-03-04 10:35:28 +08:00
|
|
|
type RegisterNodeResponse struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
InitParams *internalpb.InitParams
|
|
|
|
Status *commonpb.Status
|
2020-12-29 18:02:44 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-10-20 19:29:40 +08:00
|
|
|
- _BuildIndex_
|
2021-01-15 18:03:16 +08:00
|
|
|
|
|
|
|
```go
|
2021-03-04 10:35:28 +08:00
|
|
|
type KeyValuePair struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
Key string
|
|
|
|
Value string
|
2021-01-15 18:03:16 +08:00
|
|
|
}
|
|
|
|
|
2021-03-04 10:35:28 +08:00
|
|
|
type BuildIndexRequest struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
IndexBuildID UniqueID
|
|
|
|
IndexName string
|
|
|
|
IndexID UniqueID
|
|
|
|
DataPaths []string
|
|
|
|
TypeParams []*commonpb.KeyValuePair
|
|
|
|
IndexParams []*commonpb.KeyValuePair
|
2021-03-04 10:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type BuildIndexResponse struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
Status *commonpb.Status
|
|
|
|
IndexBuildID UniqueID
|
2021-01-15 18:03:16 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-10-20 19:29:40 +08:00
|
|
|
- _DropIndex_
|
2020-12-29 18:02:44 +08:00
|
|
|
|
|
|
|
```go
|
2021-04-12 12:45:38 +08:00
|
|
|
type DropIndexRequest struct {
|
|
|
|
IndexID UniqueID
|
2021-01-12 18:03:24 +08:00
|
|
|
}
|
2021-04-12 12:45:38 +08:00
|
|
|
```
|
|
|
|
|
2021-10-20 19:29:40 +08:00
|
|
|
- _GetIndexStates_
|
2021-01-12 18:03:24 +08:00
|
|
|
|
2021-04-12 12:45:38 +08:00
|
|
|
```go
|
|
|
|
type GetIndexStatesRequest struct {
|
|
|
|
IndexBuildIDs []UniqueID
|
2021-03-04 10:35:28 +08:00
|
|
|
}
|
|
|
|
|
2021-04-12 12:45:38 +08:00
|
|
|
const (
|
|
|
|
IndexState_IndexStateNone IndexState = 0
|
|
|
|
IndexState_Unissued IndexState = 1
|
|
|
|
IndexState_InProgress IndexState = 2
|
|
|
|
IndexState_Finished IndexState = 3
|
|
|
|
IndexState_Failed IndexState = 4
|
|
|
|
IndexState_Deleted IndexState = 5
|
|
|
|
)
|
|
|
|
|
2021-03-04 10:35:28 +08:00
|
|
|
type IndexInfo struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
State commonpb.IndexState
|
|
|
|
IndexBuildID UniqueID
|
|
|
|
IndexID UniqueID
|
|
|
|
IndexName string
|
|
|
|
Reason string
|
2020-12-27 09:05:24 +08:00
|
|
|
}
|
|
|
|
|
2021-04-12 12:45:38 +08:00
|
|
|
type GetIndexStatesResponse struct {
|
|
|
|
Status *commonpb.Status
|
|
|
|
States []*IndexInfo
|
2020-12-27 09:05:24 +08:00
|
|
|
}
|
2020-12-29 18:02:44 +08:00
|
|
|
```
|
2020-12-27 09:05:24 +08:00
|
|
|
|
2021-10-20 19:29:40 +08:00
|
|
|
- _GetIndexFilePaths_
|
2020-12-29 18:02:44 +08:00
|
|
|
|
|
|
|
```go
|
2021-04-12 12:45:38 +08:00
|
|
|
type GetIndexFilePathsRequest struct {
|
|
|
|
IndexBuildIDs []UniqueID
|
2021-03-04 10:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type IndexFilePathInfo struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
Status *commonpb.Status
|
|
|
|
IndexBuildID UniqueID
|
|
|
|
IndexFilePaths []string
|
2021-01-12 18:03:24 +08:00
|
|
|
}
|
|
|
|
|
2021-04-12 12:45:38 +08:00
|
|
|
type GetIndexFilePathsResponse struct {
|
|
|
|
Status *commonpb.Status
|
|
|
|
FilePaths []*IndexFilePathInfo
|
2020-12-27 09:05:24 +08:00
|
|
|
}
|
2021-03-04 10:35:28 +08:00
|
|
|
|
2020-12-27 09:05:24 +08:00
|
|
|
```
|
|
|
|
|
2021-10-20 19:29:40 +08:00
|
|
|
- _NotifyBuildIndex_
|
2021-02-20 10:14:03 +08:00
|
|
|
|
|
|
|
```go
|
2021-04-12 12:45:38 +08:00
|
|
|
type NotifyBuildIndexRequest struct {
|
|
|
|
Status *commonpb.Status
|
|
|
|
IndexBuildID UniqueID
|
|
|
|
IndexFilePaths []string
|
|
|
|
NodeID UniqueID
|
2021-02-20 10:14:03 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-09-24 16:14:12 +08:00
|
|
|
#### 3.3 Index Node Interface
|
2021-01-11 18:35:54 +08:00
|
|
|
|
|
|
|
```go
|
|
|
|
type IndexNode interface {
|
2021-04-12 12:45:38 +08:00
|
|
|
Component
|
|
|
|
TimeTickProvider
|
|
|
|
|
2021-10-24 08:55:27 +08:00
|
|
|
// CreateIndex receives request from IndexCoordinator to build an index.
|
|
|
|
// Index building is asynchronous, so when an index building request comes, IndexNode records the task and returns.
|
2021-04-12 12:45:38 +08:00
|
|
|
BuildIndex(ctx context.Context, req *indexpb.BuildIndexRequest) (*commonpb.Status, error)
|
2021-10-24 08:55:27 +08:00
|
|
|
// GetMetrics gets the metrics about IndexNode.
|
2021-04-12 12:45:38 +08:00
|
|
|
DropIndex(ctx context.Context, req *indexpb.DropIndexRequest) (*commonpb.Status, error)
|
2021-01-11 18:35:54 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-10-20 19:29:40 +08:00
|
|
|
- _BuildIndex_
|
2021-03-04 10:35:28 +08:00
|
|
|
|
|
|
|
```go
|
|
|
|
|
|
|
|
type KeyValuePair struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
Key string
|
|
|
|
Value string
|
2021-03-04 10:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type BuildIndexRequest struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
IndexBuildID UniqueID
|
|
|
|
IndexName string
|
|
|
|
IndexID UniqueID
|
|
|
|
DataPaths []string
|
|
|
|
TypeParams []*commonpb.KeyValuePair
|
|
|
|
IndexParams []*commonpb.KeyValuePair
|
2021-03-04 10:35:28 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-10-20 19:29:40 +08:00
|
|
|
- _DropIndex_
|
2021-03-04 10:35:28 +08:00
|
|
|
|
|
|
|
```go
|
|
|
|
type DropIndexRequest struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
IndexID UniqueID
|
2021-03-04 10:35:28 +08:00
|
|
|
}
|
|
|
|
```
|