Skip to content

Commit

Permalink
fix PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kutluhanmetin committed Aug 29, 2023
1 parent 6d44d85 commit 9792afc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
14 changes: 5 additions & 9 deletions base/commands/demo/demo_map_set_many.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ func (m MapSetManyCmd) Init(cc plug.InitContext) error {
cc.SetCommandUsage("map-setmany [entry-count] [flags]")
cc.SetPositionalArgCount(1, 1)
cc.AddStringFlag(flagName, "n", "default", false, "Name of the map.")
cc.AddStringFlag(flagSize, "", "1", false, `Maybe an integer which is number of bytes, or one of the following:
Xkb: kilobytes
Xmb: megabytes
`)
cc.AddStringFlag(flagSize, "", "", true, `Size of the map value in bytes, the following suffixes can also be used: kb, mb, e.g., 42kb)`)
help := "Generates multiple map entries."
cc.SetCommandHelp(help, help)
return nil
Expand Down Expand Up @@ -66,7 +63,7 @@ func (m MapSetManyCmd) Exec(ctx context.Context, ec plug.ExecContext) error {
}

func createEntries(ctx context.Context, entryCount int, size string, m *hazelcast.Map) error {
v, err := createVal(size)
v, err := makeValue(size)
if err != nil {
return err
}
Expand All @@ -80,16 +77,15 @@ func createEntries(ctx context.Context, entryCount int, size string, m *hazelcas
return nil
}

func createVal(size string) (string, error) {
b, err := byteSize(size)
func makeValue(size string) (string, error) {
b, err := getValueSize(size)
if err != nil {
return "", err
}
return strings.Repeat("a", int(b)), nil
}

func byteSize(sizeStr string) (int64, error) {
sizeStr = strings.TrimSpace(sizeStr)
func getValueSize(sizeStr string) (int64, error) {
sizeStr = strings.ToUpper(sizeStr)
if strings.HasSuffix(sizeStr, kb) {
sizeStr = strings.TrimSuffix(sizeStr, kb)
Expand Down
6 changes: 1 addition & 5 deletions docs/modules/ROOT/pages/clc-demo.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,7 @@ Parameters:

|`--size`
|Optional
|Maybe an integer which is number of bytes, or one of the following:

- Xkb: kilobytes

- Xmb: megabytes
|Size of the map value in bytes, the following suffixes can also be used: kb, mb, e.g., 42kb
|`1`

|===
Expand Down

0 comments on commit 9792afc

Please sign in to comment.