jerryshao commented on code in PR #10189:
URL: https://github.com/apache/gravitino/pull/10189#discussion_r2893561732
##########
server/src/main/java/org/apache/gravitino/server/web/rest/PolicyOperations.java:
##########
@@ -334,16 +333,19 @@ public Response listMetadataObjectsForPolicy(
}
static PolicyDTO toDTO(PolicyEntity policy, Optional<Boolean> inherited) {
+ String policyType =
+ policy.policyType() == Policy.BuiltInType.CUSTOM
Review Comment:
The `policyType` output is now case-inconsistent: CUSTOM returns `"custom"`
(lowercase via `policyType()`) but ICEBERG_COMPACTION returns
`"ICEBERG_COMPACTION"` (uppercase via `name()`). API consumers who switch
policy between types will see different casing. Consider normalizing to a
consistent convention (all lowercase or all uppercase), or at least add a
comment explaining the intentional difference and update the REST API
documentation.
##########
api/src/main/java/org/apache/gravitino/policy/IcebergCompactionContent.java:
##########
@@ -0,0 +1,279 @@
+/*
+ * 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.gravitino.policy;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.regex.Pattern;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.MetadataObject;
+
+/** Built-in policy content for Iceberg compaction strategy. */
+public class IcebergCompactionContent implements PolicyContent {
+ /** Property key for strategy type. */
+ public static final String STRATEGY_TYPE_KEY = "strategy.type";
+ /** Strategy type value for compaction. */
+ public static final String STRATEGY_TYPE_VALUE = "compaction";
+ /** Property key for job template name. */
+ public static final String JOB_TEMPLATE_NAME_KEY = "job.template-name";
+ /** Built-in job template name for Iceberg rewrite data files. */
+ public static final String JOB_TEMPLATE_NAME_VALUE =
"builtin-iceberg-rewrite-data-files";
+ /** Prefix for rewrite options propagated to job options. */
+ public static final String JOB_OPTIONS_PREFIX = "job.options.";
+ /** Rule key for trigger expression. */
+ public static final String TRIGGER_EXPR_KEY = "trigger-expr";
+ /** Rule key for score expression. */
+ public static final String SCORE_EXPR_KEY = "score-expr";
+ /** Rule key for minimum data file MSE threshold. */
+ public static final String MIN_DATA_FILE_MSE_KEY = "minDataFileMse";
+ /** Rule key for minimum delete file count threshold. */
+ public static final String MIN_DELETE_FILE_NUMBER_KEY =
"minDeleteFileNumber";
+ /** Rule key for data file MSE score weight. */
+ public static final String DATA_FILE_MSE_WEIGHT_KEY = "dataFileMseWeight";
+ /** Rule key for delete file number score weight. */
+ public static final String DELETE_FILE_NUMBER_WEIGHT_KEY =
"deleteFileNumberWeight";
+ /** Rule key for max partition number selected for compaction. */
+ public static final String MAX_PARTITION_NUM_KEY = "max-partition-num";
+ /** Metric name for data file MSE. */
+ public static final String DATA_FILE_MSE_METRIC = "custom-data-file-mse";
+ /** Metric name for delete file number. */
+ public static final String DELETE_FILE_NUMBER_METRIC =
"custom-delete-file-number";
+ /** Default minimum threshold for data file MSE metric. */
+ public static final long DEFAULT_MIN_DATA_FILE_MSE = 405323966463344L;
Review Comment:
This magic number should have an inline comment explaining its derivation.
The docs explain it but the source code should be self-contained:
```java
// = (128 MiB * 0.15)^2 = (134217728 * 0.15)^2
public static final long DEFAULT_MIN_DATA_FILE_MSE = 405323966463344L;
```
--
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]