@@ -6,11 +6,15 @@ import (
66 "context"
77 "fmt"
88
9+ "github.com/hazelcast/hazelcast-go-client"
10+
911 "github.com/hazelcast/hazelcast-commandline-client/base"
1012 "github.com/hazelcast/hazelcast-commandline-client/base/commands"
1113 "github.com/hazelcast/hazelcast-commandline-client/clc"
14+ "github.com/hazelcast/hazelcast-commandline-client/clc/cmd"
1215 . "github.com/hazelcast/hazelcast-commandline-client/internal/check"
1316 "github.com/hazelcast/hazelcast-commandline-client/internal/plug"
17+ "github.com/hazelcast/hazelcast-commandline-client/internal/proto/codec"
1418)
1519
1620type MapLoadAllCommand struct {}
@@ -32,21 +36,30 @@ func (MapLoadAllCommand) Exec(ctx context.Context, ec plug.ExecContext) error {
3236 name := ec .Props ().GetString (base .FlagName )
3337 _ , stop , err := ec .ExecuteBlocking (ctx , func (ctx context.Context , sp clc.Spinner ) (any , error ) {
3438 replace := ec .Props ().GetBool (mapFlagReplace )
35- keyStrs := ec .GetStringSliceArg (commands .ArgKey )
36- keys := make ([]any , len (keyStrs ))
37- kt := ec .Props ().GetString (commands .FlagKeyType )
38- keys , err := commands .MakeValuesFromStrings (kt , keyStrs )
39+ // TODO: use Map.LoadAllX methods in the Go client when they are fixed. --YT
40+ ci , err := cmd .ClientInternal (ctx , ec , sp )
3941 if err != nil {
4042 return nil , err
4143 }
42- m , err := getMap (ctx , ec , sp )
43- if err != nil {
44- return nil , err
44+ var keys []hazelcast.Data
45+ for _ , keyStr := range ec .GetStringSliceArg (commands .ArgKey ) {
46+ keyData , err := commands .MakeKeyData (ec , ci , keyStr )
47+ if err != nil {
48+ return nil , err
49+ }
50+ keys = append (keys , keyData )
4551 }
46- if replace {
47- return nil , m .LoadAllReplacing (ctx , keys ... )
52+ var req * hazelcast.ClientMessage
53+ if len (keys ) == 0 {
54+ req = codec .EncodeMapLoadAllRequest (name , replace )
55+ } else {
56+ req = codec .EncodeMapLoadGivenKeysRequest (name , keys , replace )
57+ }
58+ sp .SetText (fmt .Sprintf ("Loading keys into the Map '%s'" , name ))
59+ if _ , err = ci .InvokeOnRandomTarget (ctx , req , nil ); err != nil {
60+ return nil , err
4861 }
49- return nil , m . LoadAllWithoutReplacing ( ctx , keys ... )
62+ return nil , nil
5063 })
5164 if err != nil {
5265 return err
0 commit comments