From f2e660bd5095f93f5867f3781e8a16798677e378 Mon Sep 17 00:00:00 2001 From: InigoSJ Date: Fri, 5 Nov 2021 22:13:33 +0000 Subject: [PATCH 1/2] [BEAM-13080] Fix number of default keys --- sdks/python/apache_beam/transforms/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks/python/apache_beam/transforms/util.py b/sdks/python/apache_beam/transforms/util.py index eec07520056e9..147cc9c00e4e2 100644 --- a/sdks/python/apache_beam/transforms/util.py +++ b/sdks/python/apache_beam/transforms/util.py @@ -725,7 +725,7 @@ class Reshuffle(PTransform): """ # We use 32-bit integer as the default number of buckets. - _DEFAULT_NUM_BUCKETS = 1 << 32 + _DEFAULT_NUM_BUCKETS = (1 << 32) - 1 def __init__(self, num_buckets=None): """ From ba6aa4eb92c6f8c7367b32ac47b920a68ce58aab Mon Sep 17 00:00:00 2001 From: InigoSJ Date: Fri, 5 Nov 2021 23:44:22 +0000 Subject: [PATCH 2/2] [BEAM-13080] Fix number of default keys --- sdks/python/apache_beam/transforms/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdks/python/apache_beam/transforms/util.py b/sdks/python/apache_beam/transforms/util.py index 147cc9c00e4e2..1d7572bebaf1b 100644 --- a/sdks/python/apache_beam/transforms/util.py +++ b/sdks/python/apache_beam/transforms/util.py @@ -725,7 +725,7 @@ class Reshuffle(PTransform): """ # We use 32-bit integer as the default number of buckets. - _DEFAULT_NUM_BUCKETS = (1 << 32) - 1 + _DEFAULT_NUM_BUCKETS = 1 << 32 def __init__(self, num_buckets=None): """ @@ -744,7 +744,7 @@ def expand(self, pcoll): # type: (pvalue.PValue) -> pvalue.PCollection return ( pcoll | 'AddRandomKeys' >> - Map(lambda t: (random.randint(0, self.num_buckets), t) + Map(lambda t: (random.randrange(0, self.num_buckets), t) ).with_input_types(T).with_output_types(Tuple[int, T]) | ReshufflePerKey() | 'RemoveRandomKeys' >> Map(lambda t: t[1]).with_input_types(