5151import org .apache .druid .indexing .common .actions .RetrieveUsedSegmentsAction ;
5252import org .apache .druid .indexing .common .actions .TaskActionClient ;
5353import org .apache .druid .indexing .common .stats .RowIngestionMetersFactory ;
54+ import org .apache .druid .indexing .common .task .IndexTask .IndexTuningConfig ;
5455import org .apache .druid .indexing .common .task .batch .parallel .ParallelIndexIOConfig ;
5556import org .apache .druid .indexing .common .task .batch .parallel .ParallelIndexIngestionSpec ;
5657import org .apache .druid .indexing .common .task .batch .parallel .ParallelIndexSupervisorTask ;
7475import org .apache .druid .segment .column .ColumnHolder ;
7576import org .apache .druid .segment .column .ValueType ;
7677import org .apache .druid .segment .indexing .DataSchema ;
78+ import org .apache .druid .segment .indexing .TuningConfig ;
7779import org .apache .druid .segment .indexing .granularity .GranularitySpec ;
7880import org .apache .druid .segment .indexing .granularity .UniformGranularitySpec ;
7981import org .apache .druid .segment .loading .SegmentLoadingException ;
@@ -177,7 +179,7 @@ public CompactionTask(
177179 @ JsonProperty ("dimensionsSpec" ) @ Nullable final DimensionsSpec dimensionsSpec ,
178180 @ JsonProperty ("metricsSpec" ) @ Nullable final AggregatorFactory [] metricsSpec ,
179181 @ JsonProperty ("segmentGranularity" ) @ Nullable final Granularity segmentGranularity ,
180- @ JsonProperty ("tuningConfig" ) @ Nullable final ParallelIndexTuningConfig tuningConfig ,
182+ @ JsonProperty ("tuningConfig" ) @ Nullable final TuningConfig tuningConfig ,
181183 @ JsonProperty ("context" ) @ Nullable final Map <String , Object > context ,
182184 @ JacksonInject ObjectMapper jsonMapper ,
183185 @ JacksonInject AuthorizerMapper authorizerMapper ,
@@ -213,10 +215,10 @@ public CompactionTask(
213215 this .dimensionsSpec = dimensionsSpec == null ? dimensions : dimensionsSpec ;
214216 this .metricsSpec = metricsSpec ;
215217 this .segmentGranularity = segmentGranularity ;
216- this .tuningConfig = tuningConfig ;
218+ this .tuningConfig = tuningConfig != null ? getTuningConfig ( tuningConfig ) : null ;
217219 this .jsonMapper = jsonMapper ;
218220 this .segmentProvider = new SegmentProvider (dataSource , this .ioConfig .getInputSpec ());
219- this .partitionConfigurationManager = new PartitionConfigurationManager (tuningConfig );
221+ this .partitionConfigurationManager = new PartitionConfigurationManager (this . tuningConfig );
220222 this .authorizerMapper = authorizerMapper ;
221223 this .chatHandlerProvider = chatHandlerProvider ;
222224 this .rowIngestionMetersFactory = rowIngestionMetersFactory ;
@@ -227,6 +229,51 @@ public CompactionTask(
227229 this .appenderatorsManager = appenderatorsManager ;
228230 }
229231
232+ @ VisibleForTesting
233+ static ParallelIndexTuningConfig getTuningConfig (TuningConfig tuningConfig )
234+ {
235+ if (tuningConfig instanceof ParallelIndexTuningConfig ) {
236+ return (ParallelIndexTuningConfig ) tuningConfig ;
237+ } else if (tuningConfig instanceof IndexTuningConfig ) {
238+ final IndexTuningConfig indexTuningConfig = (IndexTuningConfig ) tuningConfig ;
239+ return new ParallelIndexTuningConfig (
240+ null ,
241+ indexTuningConfig .getMaxRowsPerSegment (),
242+ indexTuningConfig .getMaxRowsPerSegment (),
243+ indexTuningConfig .getMaxBytesInMemory (),
244+ indexTuningConfig .getMaxTotalRows (),
245+ indexTuningConfig .getNumShards (),
246+ null ,
247+ indexTuningConfig .getPartitionsSpec (),
248+ indexTuningConfig .getIndexSpec (),
249+ indexTuningConfig .getIndexSpecForIntermediatePersists (),
250+ indexTuningConfig .getMaxPendingPersists (),
251+ indexTuningConfig .isForceGuaranteedRollup (),
252+ indexTuningConfig .isReportParseExceptions (),
253+ indexTuningConfig .getPushTimeout (),
254+ indexTuningConfig .getSegmentWriteOutMediumFactory (),
255+ null ,
256+ null ,
257+ null ,
258+ null ,
259+ null ,
260+ null ,
261+ null ,
262+ null ,
263+ indexTuningConfig .isLogParseExceptions (),
264+ indexTuningConfig .getMaxParseExceptions (),
265+ indexTuningConfig .getMaxSavedParseExceptions ()
266+ );
267+ } else {
268+ throw new ISE (
269+ "Unknown tuningConfig type: [%s], Must be either [%s] or [%s]" ,
270+ tuningConfig .getClass ().getName (),
271+ ParallelIndexTuningConfig .class .getName (),
272+ IndexTuningConfig .class .getName ()
273+ );
274+ }
275+ }
276+
230277 @ JsonProperty
231278 public CompactionIOConfig getIoConfig ()
232279 {
@@ -848,7 +895,7 @@ public static class Builder
848895 @ Nullable
849896 private Granularity segmentGranularity ;
850897 @ Nullable
851- private ParallelIndexTuningConfig tuningConfig ;
898+ private TuningConfig tuningConfig ;
852899 @ Nullable
853900 private Map <String , Object > context ;
854901
@@ -911,7 +958,7 @@ public Builder segmentGranularity(Granularity segmentGranularity)
911958 return this ;
912959 }
913960
914- public Builder tuningConfig (ParallelIndexTuningConfig tuningConfig )
961+ public Builder tuningConfig (TuningConfig tuningConfig )
915962 {
916963 this .tuningConfig = tuningConfig ;
917964 return this ;
0 commit comments