|
|
@@ -21,6 +21,17 @@ import java.util.stream.StreamSupport;
|
|
|
@UtilityClass
|
|
|
public class BaseSpliteratorParalell {
|
|
|
|
|
|
+ /**
|
|
|
+ * This number tells how many additional splits are introduced into every working task.
|
|
|
+ * Value 3 means, that every fragment will be roughly 8 times shorter than "theoretical exact".
|
|
|
+ */
|
|
|
+ private static final int SPLIT_FACTOR = 3;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * This number is the minimum size of working task. Tasks with smaller size won't be split.
|
|
|
+ */
|
|
|
+ private static final int SPLIT_BOUND = 3;
|
|
|
+
|
|
|
public static <T> void forEach(Spliterator<T> that, Consumer<? super T> consumer) {
|
|
|
StreamSupport.stream(that, true).forEach(consumer);
|
|
|
}
|
|
|
@@ -164,8 +175,8 @@ public class BaseSpliteratorParalell {
|
|
|
int splits = MathUtils.log2floor(executor.getParallelism());
|
|
|
|
|
|
long n = that.getExactSizeIfKnown();
|
|
|
- for(int i = 0; i<3; i++, splits++) {
|
|
|
- if(n / (1L << splits) <= 3) {
|
|
|
+ for(int i = 0; i< SPLIT_FACTOR; i++, splits++) {
|
|
|
+ if(n / (1L << splits) <= SPLIT_BOUND) {
|
|
|
break;
|
|
|
}
|
|
|
}
|