From 3d438936c43b02be12c60d763401b56426adfb8a Mon Sep 17 00:00:00 2001 From: Wen Sun Date: Thu, 16 Mar 2023 21:25:47 +0900 Subject: [PATCH] Use the GetLoadingProgress api instead of the InMemoryPercentages in the ShowPartition api response --- client/client_grpc_partition.go | 34 ++------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/client/client_grpc_partition.go b/client/client_grpc_partition.go index 87612331e..578c6ab73 100644 --- a/client/client_grpc_partition.go +++ b/client/client_grpc_partition.go @@ -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 @@ -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 }