From 0e6ef0ee6a6f6e9f8775f5bb8f873698002408bc Mon Sep 17 00:00:00 2001 From: Kerry Donny-Clark Date: Thu, 5 Oct 2023 14:52:12 -0400 Subject: [PATCH] Fixes minor bugs.` --- sdks/go/pkg/beam/options/resource/hint.go | 12 ++++++------ .../sdk/transforms/resourcehints/ResourceHints.java | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/sdks/go/pkg/beam/options/resource/hint.go b/sdks/go/pkg/beam/options/resource/hint.go index 798a2bcd6f7c..58ce647a6fb1 100644 --- a/sdks/go/pkg/beam/options/resource/hint.go +++ b/sdks/go/pkg/beam/options/resource/hint.go @@ -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 { @@ -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 { @@ -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))) } \ No newline at end of file diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/resourcehints/ResourceHints.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/resourcehints/ResourceHints.java index 0699da18204b..2a25d5f4e298 100644 --- a/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/resourcehints/ResourceHints.java +++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/resourcehints/ResourceHints.java @@ -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