imply-cheddar commented on code in PR #14507:
URL: https://github.com/apache/druid/pull/14507#discussion_r1253981046


##########
indexing-service/src/main/java/org/apache/druid/indexing/input/DruidInputSource.java:
##########
@@ -493,23 +536,18 @@ public static List<TimelineObjectHolder<String, 
DataSegment>> getTimelineForInte
   {
     Preconditions.checkNotNull(interval);
 
-    // This call used to use the TaskActionClient, so for compatibility we use 
the same retry configuration
-    // as TaskActionClient.
     final RetryPolicy retryPolicy = retryPolicyFactory.makeRetryPolicy();
     Collection<DataSegment> usedSegments;
     while (true) {
       try {
-        usedSegments = 
coordinatorClient.fetchUsedSegmentsInDataSourceForIntervals(
-            dataSource,
-            Collections.singletonList(interval)
-        );
+        usedSegments = fetchUsedSegmentsForInterval(toolbox, 
coordinatorClient, dataSource, interval);

Review Comment:
   Random nit: I'm not sure this really benefits from being a method?  It's not 
called from any other place, so it feels like it's just creating a method to 
create a method.  Might as well just in-line it.



##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexSupervisorTask.java:
##########
@@ -156,7 +157,7 @@ public class ParallelIndexSupervisorTask extends 
AbstractBatchIndexTask implemen
    * Only the compaction task can have a special base name.
    */
   private final String baseSubtaskSpecName;
-  private final InputSource baseInputSource;
+  private InputSource baseInputSource;

Review Comment:
   Making this not final is bad.  Don't do that.  From looking at the code, the 
input source gets used in a number of places and the order of methods being 
called is going to change what happens when those methods are called.  You 
should switch this to an AtomicReference that you access through a private 
method which lazily instantiates the object.



##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/IndexTask.java:
##########
@@ -1199,6 +1201,15 @@ public InputSource getInputSource()
       return inputSource;
     }
 
+    public InputSource getNonNullInputSource(TaskToolbox toolbox)
+    {
+      Preconditions.checkNotNull(inputSource, "inputSource");
+      if (inputSource instanceof TaskInputSource && toolbox != null) {
+        return ((TaskInputSource) inputSource).withTaskToolbox(toolbox);
+      }
+      return inputSource;
+    }

Review Comment:
   If this gets called multiple times, it's gonna call `withTaskToolbox` 
multiple times.  returning different objects each time.  That's not good.
   
   You should be doing this before setting the `inputSource`, not lazily here.



##########
indexing-service/src/main/java/org/apache/druid/indexing/input/TaskInputSource.java:
##########
@@ -0,0 +1,28 @@
+/*
+ * 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.input;
+
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.indexing.common.TaskToolbox;
+
+public interface TaskInputSource extends InputSource
+{
+  InputSource withTaskToolbox(TaskToolbox toolbox);
+}

Review Comment:
   Javadoc please.



-- 
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]

Reply via email to