pnowojski commented on a change in pull request #7051: [FLINK-10820][network] 
Simplify the RebalancePartitioner implementation
URL: https://github.com/apache/flink/pull/7051#discussion_r232605133
 
 

 ##########
 File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/partitioner/RebalancePartitioner.java
 ##########
 @@ -33,29 +33,18 @@
 public class RebalancePartitioner<T> extends StreamPartitioner<T> {
        private static final long serialVersionUID = 1L;
 
-       private final int[] returnArray = {Integer.MAX_VALUE - 1};
+       private final int[] returnArray = { -1 };
 
 Review comment:
   `-1` is somehow better magic value, but it is still a magic value. This code 
would be cleaner if you had introduced `private boolean isInitialized = false;` 
variable and check against it instead of `returnArray[0] == -1`. It could also 
be a bit more efficient (more JIT/branch prediction friendly and could save 
some cached memory reads).
   
   However the proper fix would be to introduce some kind of `open(int 
numChannels)` (or `initialize(...)`) method. This is a reoccurring issue with 
our `ChannelSelector`s that they have broken/missing initialisation logic. 
   
   What do you think about this? I would be in favour of the proper fix, but I 
won't object if you decide that it's out of the scope :) 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to