2020-12-27 09:05:24 +08:00
|
|
|
|
|
|
|
|
|
|
|
## 8. Index Service
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### 8.1 Overview
|
|
|
|
|
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-01-13 11:08:03 +08:00
|
|
|
#### 8.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-04-12 12:45:38 +08:00
|
|
|
Component
|
|
|
|
TimeTickProvider
|
|
|
|
|
|
|
|
RegisterNode(ctx context.Context, req *indexpb.RegisterNodeRequest) (*indexpb.RegisterNodeResponse, error)
|
|
|
|
BuildIndex(ctx context.Context, req *indexpb.BuildIndexRequest) (*indexpb.BuildIndexResponse, error)
|
|
|
|
DropIndex(ctx context.Context, req *indexpb.DropIndexRequest) (*commonpb.Status, error)
|
|
|
|
GetIndexStates(ctx context.Context, req *indexpb.IndexStatesRequest) (*indexpb.IndexStatesResponse, error)
|
|
|
|
GetIndexFilePaths(ctx context.Context, req *indexpb.IndexFilePathsRequest) (*indexpb.IndexFilePathsResponse, error)
|
|
|
|
NotifyBuildIndex(ctx context.Context, nty *indexpb.BuildIndexNotification) (*commonpb.Status, error)
|
2020-12-29 18:02:44 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-13 11:08:03 +08:00
|
|
|
* *RegisterNode*
|
|
|
|
|
|
|
|
```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-03-04 10:35:28 +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-04-12 12:45:38 +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
|
|
|
```
|
|
|
|
|
|
|
|
* *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
|
|
|
|
2020-12-29 18:02:44 +08:00
|
|
|
* *GetIndexFilePaths*
|
|
|
|
|
|
|
|
```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-03-04 10:35:28 +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-01-11 18:35:54 +08:00
|
|
|
|
|
|
|
|
2021-01-13 11:08:03 +08:00
|
|
|
#### 8.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
|
|
|
|
|
|
|
|
BuildIndex(ctx context.Context, req *indexpb.BuildIndexRequest) (*commonpb.Status, error)
|
|
|
|
DropIndex(ctx context.Context, req *indexpb.DropIndexRequest) (*commonpb.Status, error)
|
2021-01-11 18:35:54 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-03-04 10:35:28 +08:00
|
|
|
* *BuildIndex*
|
|
|
|
|
|
|
|
```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
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
* *DropIndex*
|
|
|
|
|
|
|
|
```go
|
|
|
|
type DropIndexRequest struct {
|
2021-04-12 12:45:38 +08:00
|
|
|
IndexID UniqueID
|
2021-03-04 10:35:28 +08:00
|
|
|
}
|
|
|
|
```
|