Skip to content

Commit

Permalink
Fixes minor bugs.`
Browse files Browse the repository at this point in the history
  • Loading branch information
kerrydc committed Oct 5, 2023
1 parent 2164eca commit 0e6ef0e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
12 changes: 6 additions & 6 deletions sdks/go/pkg/beam/options/resource/hint.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,12 @@ func (h acceleratorHint) String() string {
//
// See https://beam.apache.org/documentation/runtime/resource-hints/ for more information about
// resource hints.
func CPUCount(v int) Hint {
return CPUCountHint{value: int(v)}
func CPUCount(v uint64) Hint {
return CPUCountHint{value: uint64(v)}
}

type CPUCountHint struct {
value int
value uint64
}

func (CPUCountHint) URN() string {
Expand All @@ -218,10 +218,10 @@ func (CPUCountHint) URN() string {
func (h CPUCountHint) Payload() []byte {
// Go strings are utf8, and if the string is ascii,
// byte conversion handles that directly.
return []byte(strconv.FormatInt(h.value, 10))
return []byte(strconv.FormatUint(h.value, 10))
}

// MergeWith an outer minRAMHints by keeping the maximum of the two cpu counts.
// MergeWith an outer CPUCountHints by keeping the maximum of the two cpu counts.
func (h CPUCountHint) MergeWithOuter(outer Hint) Hint {
// Intentional runtime panic from type assertion to catch hint merge errors.
if outer.(CPUCountHint).value > h.value {
Expand All @@ -231,5 +231,5 @@ func (h CPUCountHint) MergeWithOuter(outer Hint) Hint {
}

func (h CPUCountHint) String() string {
return fmt.Sprintf("cpu_count=%v", humanize.Bytes(int(h.value)))
return fmt.Sprintf("cpu_count=%v", humanize.Bytes(uint64(h.value)))
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ public IntHint(int value) {

public static int parse(String s) {
return Integer.valueOf(s);
throw new IllegalArgumentException("Unable to parse '" + s + "' as an Integer value.");
}

@Override
Expand Down

0 comments on commit 0e6ef0e

Please sign in to comment.