syhily commented on code in PR #20584:
URL: https://github.com/apache/flink/pull/20584#discussion_r981989749


##########
flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/enumerator/topic/range/SplitRangeGenerator.java:
##########
@@ -27,27 +28,55 @@
 import java.util.List;
 
 import static 
org.apache.flink.connector.pulsar.source.enumerator.topic.TopicRange.MAX_RANGE;
-import static 
org.apache.flink.connector.pulsar.source.enumerator.topic.TopicRange.RANGE_SIZE;
+import static 
org.apache.flink.connector.pulsar.source.enumerator.topic.TopicRange.MIN_RANGE;
+import static org.apache.flink.util.Preconditions.checkArgument;
 
 /**
  * This range generator would divide the range by the flink source 
parallelism. It would be the
  * default implementation for {@link SubscriptionType#Key_Shared} subscription.
  */
-public class UniformRangeGenerator implements RangeGenerator {
-    private static final long serialVersionUID = -7292650922683609268L;
+@PublicEvolving
+public class SplitRangeGenerator implements RangeGenerator {
+    private static final long serialVersionUID = -8682286436352905249L;
+
+    private final int start;
+    private final int end;
+
+    public SplitRangeGenerator() {
+        this(MIN_RANGE, MAX_RANGE);
+    }
+
+    public SplitRangeGenerator(int start, int end) {
+        checkArgument(
+                start >= MIN_RANGE,
+                "Start range should be equal to or great than the min range " 
+ MIN_RANGE);
+        checkArgument(
+                end <= MAX_RANGE, "End range should below or less than the max 
range " + MAX_RANGE);
+        checkArgument(start <= end, "Start range should be equal to or less 
than the end range");
+
+        this.start = start;
+        this.end = end;
+    }
 
     @Override
     public List<TopicRange> range(TopicMetadata metadata, int parallelism) {

Review Comment:
   Yep. You are right.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to