Skip to content

[flink] Support BUCKET_LOAD_BALANCE shuffle strategy for table with bucket kyes. - #4450

Open
loserwang1024 wants to merge 2 commits into
apache:mainfrom
loserwang1024:shuffle-bucket
Open

loserwang1024 wants to merge 2 commits into
apache:mainfrom
loserwang1024:shuffle-bucket

Conversation

@loserwang1024

Copy link
Copy Markdown
Contributor

Purpose

Linked issue: close #4449

Brief change log

Tests

API and Format

Documentation

@leonardBang
leonardBang self-requested a review September 21, 2026 08:49
* @param bucketingFunction the bucketing function for computing the bucket ID
* @return channel index in {@code [0, numChannels)}
*/
public static int routeByBucket(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sharing one routing implementation between the sink shuffle and the lookup partitioner looks like the right direction — it removes the duplicated gcd/slot logic and stops the two algorithms from drifting apart. The owner feels a bit off, though: this static helper lives on a ChannelComputer implementation in the sink package, while FlussLookupInputPartitioner is in source.lookup and reaches it through a fully qualified name (FlussLookupInputPartitioner.java:133) without ever constructing a ChannelComputer.

Would it make sense to move the shared algorithm to a neutral internal home, e.g. flink.shuffle.BucketLoadBalanceRouter#route(...) (clearest ownership), or at least into flink.sink.shuffle next to DistributionMode, so both callers can use a regular import? If more callers show up later, static helpers would otherwise keep piling onto this class.

Two details that could ride along, if useful: the "evenly divisible" fast path is currently encoded twice (routeByBucket:160 and ChannelComputer#select:91), and on the lookup side lookupKeyEncoder.encodeKey(...) now runs before that check (FlussLookupInputPartitioner.java:128), so the divisible case pays one extra key encoding per probe key where it used to return early.

@loserwang1024

Copy link
Copy Markdown
Contributor Author

@leonardBang , I have rebase this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce a new sink distribution mode BUCKET_LOAD_BALANCE for the Flink connector.

2 participants