jerryshao commented on code in PR #10189:
URL: https://github.com/apache/gravitino/pull/10189#discussion_r2894027954
##########
common/src/main/java/org/apache/gravitino/dto/policy/PolicyContentDTO.java:
##########
@@ -69,4 +75,133 @@ public Map<String, String> properties() {
return properties;
}
}
+
+ /** Represents a typed iceberg compaction policy content DTO. */
+ @EqualsAndHashCode
+ @ToString
+ @Builder(setterPrefix = "with")
+ @AllArgsConstructor(access = lombok.AccessLevel.PRIVATE)
+ class IcebergCompactionContentDTO implements PolicyContentDTO {
+
+ @JsonProperty("minDataFileMse")
+ @JsonAlias("minDatafileMse")
+ private Long minDataFileMse;
+
+ @JsonProperty("minDeleteFileNumber")
+ private Long minDeleteFileNumber;
+
+ @JsonProperty("dataFileMseWeight")
+ @JsonAlias("datafileMseWeight")
+ private Long dataFileMseWeight;
+
+ @JsonProperty("deleteFileNumberWeight")
+ private Long deleteFileNumberWeight;
+
+ @JsonProperty("maxPartitionNum")
+ private Long maxPartitionNum;
+
+ @JsonProperty("rewriteOptions")
+ private Map<String, String> rewriteOptions;
+
+ // Default constructor for Jackson deserialization only.
+ private IcebergCompactionContentDTO() {}
+
+ /**
+ * Returns the minimum threshold for custom-data-file-mse metric.
+ *
+ * @return minimum data file MSE threshold
+ */
+ public Long minDataFileMse() {
+ return minDataFileMse == null
+ ? IcebergCompactionContent.DEFAULT_MIN_DATA_FILE_MSE
+ : minDataFileMse;
+ }
+
+ /**
+ * Returns the minimum threshold for custom-delete-file-number metric.
+ *
+ * @return minimum delete file number threshold
+ */
+ public Long minDeleteFileNumber() {
+ return minDeleteFileNumber == null
+ ? IcebergCompactionContent.DEFAULT_MIN_DELETE_FILE_NUMBER
+ : minDeleteFileNumber;
+ }
+
+ /**
+ * Returns the weight for custom-data-file-mse metric in score expression.
+ *
+ * @return data file MSE score weight
+ */
+ public Long dataFileMseWeight() {
+ return dataFileMseWeight == null
+ ? IcebergCompactionContent.DEFAULT_DATA_FILE_MSE_WEIGHT
+ : dataFileMseWeight;
+ }
+
+ /**
+ * Returns the weight for custom-delete-file-number metric in score
expression.
+ *
+ * @return delete file number score weight
+ */
+ public Long deleteFileNumberWeight() {
+ return deleteFileNumberWeight == null
+ ? IcebergCompactionContent.DEFAULT_DELETE_FILE_NUMBER_WEIGHT
+ : deleteFileNumberWeight;
+ }
+
+ /**
+ * Returns max partition number selected for compaction.
+ *
+ * @return max partition number
+ */
+ public Long maxPartitionNum() {
+ return maxPartitionNum == null
+ ? IcebergCompactionContent.DEFAULT_MAX_PARTITION_NUM
+ : maxPartitionNum;
+ }
+
+ /**
+ * Returns rewrite options expanded to job.options.* during rule
generation.
+ *
+ * @return rewrite options map
+ */
+ public Map<String, String> rewriteOptions() {
+ return rewriteOptions == null
+ ? IcebergCompactionContent.DEFAULT_REWRITE_OPTIONS
+ : Collections.unmodifiableMap(new LinkedHashMap<>(rewriteOptions));
+ }
+
+ @Override
+ public Set<MetadataObject.Type> supportedObjectTypes() {
+ return ImmutableSet.of(
+ MetadataObject.Type.CATALOG, MetadataObject.Type.SCHEMA,
MetadataObject.Type.TABLE);
Review Comment:
`supportedObjectTypes()` duplicates
`IcebergCompactionContent.SUPPORTED_OBJECT_TYPES` directly. The delegation
pattern is already established via `toDomainContent()` for `properties()`,
`rules()`, and `validate()` — `supportedObjectTypes()` should follow the same
pattern:
```java
@Override
public Set<MetadataObject.Type> supportedObjectTypes() {
return toDomainContent().supportedObjectTypes();
}
```
This ensures a single source of truth: if supported types ever expand (e.g.
adding `FILESET`), only `IcebergCompactionContent.SUPPORTED_OBJECT_TYPES` needs
updating.
--
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]