clintropolis commented on code in PR #14695:
URL: https://github.com/apache/druid/pull/14695#discussion_r1295491565


##########
processing/src/main/java/org/apache/druid/query/DruidProcessingConfig.java:
##########
@@ -19,45 +19,85 @@
 
 package org.apache.druid.query;
 
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.annotations.VisibleForTesting;
 import org.apache.druid.java.util.common.HumanReadableBytes;
 import org.apache.druid.java.util.common.IAE;
-import org.apache.druid.java.util.common.concurrent.ExecutorServiceConfig;
-import org.apache.druid.java.util.common.guava.ParallelMergeCombiningSequence;
 import org.apache.druid.java.util.common.logger.Logger;
 import org.apache.druid.segment.column.ColumnConfig;
 import org.apache.druid.utils.JvmUtils;
-import org.skife.config.Config;
 
+import javax.annotation.Nullable;
 import java.util.concurrent.atomic.AtomicReference;
 
-public abstract class DruidProcessingConfig extends ExecutorServiceConfig 
implements ColumnConfig
+public class DruidProcessingConfig implements ColumnConfig
 {
   private static final Logger log = new Logger(DruidProcessingConfig.class);
 
-  public static final int DEFAULT_NUM_MERGE_BUFFERS = -1;
-  public static final HumanReadableBytes DEFAULT_PROCESSING_BUFFER_SIZE_BYTES 
= HumanReadableBytes.valueOf(-1);
-  public static final int MAX_DEFAULT_PROCESSING_BUFFER_SIZE_BYTES = 1024 * 
1024 * 1024;
-  public static final int DEFAULT_MERGE_POOL_AWAIT_SHUTDOWN_MILLIS = 60_000;
-  public static final int DEFAULT_INITIAL_BUFFERS_FOR_INTERMEDIATE_POOL = 0;
-
-  private AtomicReference<Integer> computedBufferSizeBytes = new 
AtomicReference<>();
-
-  @Config({"druid.computation.buffer.size", "${base_path}.buffer.sizeBytes"})
-  public HumanReadableBytes intermediateComputeSizeBytesConfigured()
+  public static long computeMaxMemoryFromMaxHeapSize()
   {
-    return DEFAULT_PROCESSING_BUFFER_SIZE_BYTES;
+    return Runtime.getRuntime().maxMemory() / 4;
   }
 
-  public int intermediateComputeSizeBytes()
-  {
-    HumanReadableBytes sizeBytesConfigured = 
intermediateComputeSizeBytesConfigured();
-    if (!DEFAULT_PROCESSING_BUFFER_SIZE_BYTES.equals(sizeBytesConfigured)) {
+  @JsonProperty
+  private final String formatString;
+  @JsonProperty
+  private final int numThreads;
+  @JsonProperty
+  private final int numMergeBuffers;
+  @JsonProperty
+  private final boolean fifo;
+  @JsonProperty
+  private final String tmpDir;
+  @JsonProperty
+  private final DruidProcessingBufferConfig buffer;
+  @JsonProperty
+  private final DruidProcessingIndexesConfig indexes;
+  private final AtomicReference<Integer> computedBufferSizeBytes = new 
AtomicReference<>();
+  private final boolean numThreadsConfigured;
+  private final boolean numMergeBuffersConfigured;
+
+  @JsonCreator
+  public DruidProcessingConfig(
+      @JsonProperty("formatString") @Nullable String formatString,
+      @JsonProperty("numThreads") @Nullable Integer numThreads,
+      @JsonProperty("numMergeBuffers") @Nullable Integer numMergeBuffers,
+      @JsonProperty("fifo") @Nullable Boolean fifo,
+      @JsonProperty("tmpDir") @Nullable String tmpDir,
+      @JsonProperty("buffer") DruidProcessingBufferConfig buffer,
+      @JsonProperty("indexes") DruidProcessingIndexesConfig indexes
+  )
+  {
+    this.formatString = formatString == null ? "processing-%s" : formatString;
+    this.numThreads = numThreads == null
+                      ? 
Math.max(JvmUtils.getRuntimeInfo().getAvailableProcessors() - 1, 1)
+                      : numThreads;
+    this.numMergeBuffers = numMergeBuffers == null ? Math.max(2, 
this.numThreads / 4) : numMergeBuffers;
+    this.fifo = fifo == null || fifo;
+    this.tmpDir = tmpDir == null ? System.getProperty("java.io.tmpdir") : 
tmpDir;

Review Comment:
   cool, didn't know that existed, changed to use this where appropriate



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