maytasm3 commented on a change in pull request #9448: Fix superbatch merge last 
partition boundaries
URL: https://github.com/apache/druid/pull/9448#discussion_r386628214
 
 

 ##########
 File path: 
indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexSupervisorTaskTest.java
 ##########
 @@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.indexing.common.task.batch.parallel;
+
+import org.apache.druid.java.util.common.Intervals;
+import org.apache.druid.java.util.common.Pair;
+import org.joda.time.Interval;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.runners.Enclosed;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+@RunWith(Enclosed.class)
+public class ParallelIndexSupervisorTaskTest
+{
+  @RunWith(Parameterized.class)
+  public static class CreateMergeIoConfigsTest
+  {
+    private static final Function<List<HashPartitionLocation>, 
PartialHashSegmentMergeIOConfig>
+        CREATE_PARTIAL_SEGMENT_MERGE_IO_CONFIG = 
PartialHashSegmentMergeIOConfig::new;
+
+    @Parameterized.Parameters(name = "count = {0}")
+    public static Iterable<? extends Object> data()
+    {
+      // different scenarios for last (index = 10 - 1 = 9) partition:
+      return Arrays.asList(
+          20,  // even partitions per task: round(20 / 10) * (10 - 1) = 2 * 9 
= 18 < 20
+          24,  // round down:               round(24 / 10) * (10 - 1) = 2 * 9 
= 18 < 24
+          25,  // round up to greater:      round(25 / 10) * (10 - 1) = 3 * 9 
= 27 > 25 (index out of bounds)
+          27   // round up to equal:        round(27 / 10) * (10 - 1) = 3 * 9 
= 27 == 27 (empty partition)
+      );
+    }
+
+    @Parameterized.Parameter
+    public int count;
+
+    @Test
+    public void handlesLastPartitionCorrectly()
 
 Review comment:
   Some ideas for other assertions.
   1) Verify that the split is evenly distributed. i.e. we should have 10 tasks 
with 2 each (for 20), 4 tasks with 3 and 6 tasks with 2 (for 24), etc.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to