JNSimba commented on code in PR #329:
URL:
https://github.com/apache/doris-spark-connector/pull/329#discussion_r2188902959
##########
spark-doris-connector/spark-doris-connector-base/src/main/java/org/apache/doris/spark/util/LoadBalanceList.java:
##########
@@ -0,0 +1,38 @@
+package org.apache.doris.spark.util;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Random;
+
+
+public class LoadBalanceList<T> implements Iterable<T> {
+
+ private final List<T> list;
+
+ public LoadBalanceList(List<T> servers) {
+ this.list = Collections.unmodifiableList(servers);
+ }
+
+ @Override
+ public Iterator<T> iterator() {
+ return new Iterator<T>() {
+ final int offset = Math.abs(new Random().nextInt());
Review Comment:
If we set offset=0, the result of the operation may still be 1 every time?
Because it is a new Iterator every time?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]