Skip to content

Commit

Permalink
Use the GetLoadingProgress api instead of the InMemoryPercentages in …
Browse files Browse the repository at this point in the history
…the ShowPartition api response
  • Loading branch information
xwjdsh committed Mar 16, 2023
1 parent 7fb93bf commit 3d43893
Showing 1 changed file with 2 additions and 32 deletions.
34 changes: 2 additions & 32 deletions client/client_grpc_partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,23 +149,6 @@ func (c *GrpcClient) LoadPartitions(ctx context.Context, collName string, partit
return err
}
}
partitions, err := c.ShowPartitions(ctx, collName)
if err != nil {
return err
}
m := make(map[string]int64)
for _, partition := range partitions {
m[partition.Name] = partition.ID
}
// load partitions ids
ids := make(map[int64]struct{})
for _, partitionName := range partitionNames {
id, has := m[partitionName]
if !has {
return fmt.Errorf("Collection %s does not has partitions %s", collName, partitionName)
}
ids[id] = struct{}{}
}

req := &server.LoadPartitionsRequest{
DbName: "", // reserved
Expand All @@ -187,24 +170,11 @@ func (c *GrpcClient) LoadPartitions(ctx context.Context, collName string, partit
return errors.New("context deadline exceeded")
default:
}
partitions, err := c.ShowPartitions(ctx, collName)
percentage, err := c.GetLoadingProgress(ctx, collName, partitionNames)
if err != nil {
return err
}
foundLoading := false
loaded := 0
for _, partition := range partitions {
if _, has := ids[partition.ID]; !has {
continue
}
if !partition.Loaded {
//Not loaded
foundLoading = true
break
}
loaded++
}
if foundLoading || loaded < len(partitionNames) {
if percentage != 100 {
time.Sleep(time.Millisecond * 100)
continue
}
Expand Down

0 comments on commit 3d43893

Please sign in to comment.