This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch 
gh-readonly-queue/main/pr-8246-68e1f384ac12f353f7184e48e4699c5e99eb0b5d
in repository https://gitbox.apache.org/repos/asf/texera.git

commit 22b0518731a169c323a3f0683904ed94537c0d5c
Author: carloea2 <[email protected]>
AuthorDate: Mon Nov 16 22:19:30 2026 +0000

    feat(pyamber): route ranges by unique receivers (#8246)
    
    ### What changes were proposed in this PR?
    
    Use the unique receiver count when dividing the range. The planner
    includes every sender-receiver pair, so counting channels makes the
    Python bucket index too large when a range link has multiple senders.
    
    For two senders and two receivers over -10 to 9, key 9 previously raised
    `IndexError`. It now reaches receiver B, matching the JVM partitioner.
    
    ### Any related issues, documentation, discussions?
    
    Closes #8245. Provides the receiver-count change discussed in #8258.
    
    ### How was this PR tested?
    
    Added the OutputManager regression before changing production code: four
    multi-sender cases failed with `IndexError`; both single-sender controls
    passed. The six cases cover one to three senders, one or two receivers,
    partition boundaries, and values outside the range.
    
    Also executed `LinkConfig.toPartitioning` on JDK 17 and passed its
    serialized configurations into Python OutputManager. All six matched the
    regression configurations byte for byte and passed after the change.
    This checks planner configuration and worker output dispatch, without
    running a complete workflow.
    
    With Python 3.12 and `PYTHONPATH=src/main/python`, from `amber`:
    
    ```text
    python -m pytest 
src/test/python/core/architecture/packaging/test_output_manager.py 
src/test/python/core/architecture/sendsemantics -q --tb=short -p 
no:cacheprovider
    83 passed
    
    python -m pytest src/test/python/core/architecture 
src/test/python/core/runnables -q --tb=short -p no:cacheprovider
    567 passed
    
    ruff check src/main/python src/test/python
    All checks passed
    
    ruff format --check src/main/python src/test/python
    217 files already formatted
    ```
    
    `git diff --check` passed.
    
    ### Was this PR authored or co-authored using generative AI tooling?
    
    Generated-by: Codex (GPT-6)
---
 .../range_based_shuffle_partitioner.py             |  5 +---
 .../architecture/packaging/test_output_manager.py  | 30 ++++++++++++++++++++++
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git 
a/amber/src/main/python/core/architecture/sendsemantics/range_based_shuffle_partitioner.py
 
b/amber/src/main/python/core/architecture/sendsemantics/range_based_shuffle_partitioner.py
index 3059e8db41..6d15f05011 100644
--- 
a/amber/src/main/python/core/architecture/sendsemantics/range_based_shuffle_partitioner.py
+++ 
b/amber/src/main/python/core/architecture/sendsemantics/range_based_shuffle_partitioner.py
@@ -36,10 +36,7 @@ class 
RangeBasedShufflePartitioner(IndexedShufflePartitioner):
         self.range_min = partitioning.range_min
         self.range_max = partitioning.range_max
         self.keys_per_receiver = int(
-            (
-                (partitioning.range_max - partitioning.range_min)
-                // len(partitioning.channels)
-            )
+            ((partitioning.range_max - partitioning.range_min) // 
len(self.receivers))
             + 1
         )
 
diff --git 
a/amber/src/test/python/core/architecture/packaging/test_output_manager.py 
b/amber/src/test/python/core/architecture/packaging/test_output_manager.py
index 841e122be6..defdc609fb 100644
--- a/amber/src/test/python/core/architecture/packaging/test_output_manager.py
+++ b/amber/src/test/python/core/architecture/packaging/test_output_manager.py
@@ -579,6 +579,36 @@ class TestEmitChain:
         assert isinstance(frame, DataFrame)
         assert frame.frame.to_pydict() == {"k": [1, 2], "v": ["a", "b"]}
 
+    @pytest.mark.parametrize("sender_count", [1, 2, 3])
+    @pytest.mark.parametrize("receivers", [("A",), ("A", "B")])
+    def test_range_shuffle_with_planner_channels(
+        self, output_manager, link, sender_count, receivers
+    ):
+        # LinkConfig.toPartitioning includes every sender-receiver pair.
+        senders = [_WORKER_ID, "other-1", "other-2"][:sender_count]
+        partitioning = RangeBasedShufflePartitioning(
+            batch_size=1,
+            channels=[
+                ChannelIdentity(
+                    from_worker_id=_worker(sender), 
to_worker_id=_worker(receiver)
+                )
+                for sender in senders
+                for receiver in receivers
+            ],
+            range_attribute_names=["k"],
+            range_min=-10,
+            range_max=9,
+        )
+        output_manager.add_partitioning(link, set_one_of(Partitioning, 
partitioning))
+        assert len(output_manager.get_output_channel_ids()) == len(receivers)
+
+        expected = ["A"] * 6 if len(receivers) == 1 else ["B", "A", "A", "A", 
"B", "B"]
+        for value, receiver in zip([9, -11, -10, -1, 0, 10], expected):
+            out = list(output_manager.tuple_to_batch(Tuple({"k": value, "v": 
"a"})))
+            assert len(out) == 1
+            assert out[0][0] == _worker(receiver)
+            assert out[0][1].frame.to_pydict() == {"k": [value], "v": ["a"]}
+
     def test_tuple_to_batch_fans_out_to_every_partitioner(self, 
output_manager):
         # Two downstream links: the same tuple must reach both, in the
         # order the partitionings were added.

Reply via email to