You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2021/11/03 07:23:56 UTC

[GitHub] [druid] kfaraz commented on a change in pull request #11848: Add support for multi dimension range partitioning

kfaraz commented on a change in pull request #11848:
URL: https://github.com/apache/druid/pull/11848#discussion_r741665781



##########
File path: core/src/main/java/org/apache/druid/indexer/partitions/MultiDimensionPartitionsSpec.java
##########
@@ -0,0 +1,232 @@
+/*
+ * 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.indexer.partitions;
+
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import org.apache.druid.indexer.Checks;
+import org.apache.druid.indexer.Property;
+
+import javax.annotation.Nullable;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Partition a segment by multiple dimensions.
+ */
+public class MultiDimensionPartitionsSpec implements DimensionBasedPartitionsSpec
+{
+  public static final String NAME = "multi_dim";
+
+  private static final String PARITION_DIMENSIONS = "partitionDimensions";
+
+  private static final String FORCE_GUARANTEED_ROLLUP_COMPATIBLE = "";
+
+  private final Integer targetRowsPerSegment;
+  private final Integer maxRowsPerSegment;
+  private final List<String> partitionDimensions;
+  private final boolean assumeGrouped;
+
+  // Value of this field is derived from targetRows and maxRows
+  private final int resolvedMaxRowPerSegment;
+
+  @JsonCreator
+  public MultiDimensionPartitionsSpec(
+      @JsonProperty(TARGET_ROWS_PER_SEGMENT) @Nullable Integer targetRowsPerSegment,
+      @JsonProperty(MAX_ROWS_PER_SEGMENT) @Nullable Integer maxRowsPerSegment,
+      @JsonProperty(PARITION_DIMENSIONS) List<String> partitionDimensions,
+      @JsonProperty("assumeGrouped") boolean assumeGrouped,  // false by default
+
+      // Deprecated properties preserved for backward compatibility:
+      @Deprecated @JsonProperty(TARGET_PARTITION_SIZE) @Nullable
+          Integer targetPartitionSize,  // prefer targetRowsPerSegment
+      @Deprecated @JsonProperty(MAX_PARTITION_SIZE) @Nullable
+          Integer maxPartitionSize  // prefer maxRowsPerSegment
+  )
+  {
+    Preconditions.checkArgument(partitionDimensions != null, "partitionDimensions must be specified");
+    this.partitionDimensions = partitionDimensions;
+    this.assumeGrouped = assumeGrouped;
+
+    Integer adjustedTargetRowsPerSegment = PartitionsSpec.resolveHistoricalNullIfNeeded(targetRowsPerSegment);
+    Integer adjustedMaxRowsPerSegment = PartitionsSpec.resolveHistoricalNullIfNeeded(maxRowsPerSegment);
+    Integer adjustedTargetPartitionSize = PartitionsSpec.resolveHistoricalNullIfNeeded(targetPartitionSize);
+    Integer adjustedMaxPartitionSize = PartitionsSpec.resolveHistoricalNullIfNeeded(maxPartitionSize);
+
+    Property<Integer> target = Checks.checkAtMostOneNotNull(
+        DimensionBasedPartitionsSpec.TARGET_ROWS_PER_SEGMENT,
+        adjustedTargetRowsPerSegment,
+        DimensionBasedPartitionsSpec.TARGET_PARTITION_SIZE,
+        adjustedTargetPartitionSize
+    );
+
+    Property<Integer> max = Checks.checkAtMostOneNotNull(

Review comment:
       Removed deprecated fields from multi dim.




-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org