capistrant commented on code in PR #18939: URL: https://github.com/apache/druid/pull/18939#discussion_r2813661753
########## server/src/main/java/org/apache/druid/server/compaction/InlineReindexingRuleProvider.java: ########## @@ -0,0 +1,421 @@ +/* + * 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.server.compaction; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.druid.common.config.Configs; +import org.joda.time.DateTime; +import org.joda.time.Interval; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; + +/** + * Rule provider that returns a static list of rules defined inline in the configuration. + * <p> + * This is the simplest provider implementation, suitable for testing and use cases where the number of rules is + * relatively small and can be defined directly in the supervisor spec. + * <p> + * When filtering rules by interval, this provider only returns rules where {@link ReindexingRule#appliesTo(Interval, DateTime)} + * returns {@link ReindexingRule.AppliesToMode#FULL}. Rules with partial or no overlap are excluded. + * <p> + * For non-additive rule types, when multiple rules fully match an interval, only the rule with the oldest threshold + * (largest period) is returned. For example, if both a P30D and P90D granularity rule match an interval, the P90D + * rule is selected because it has the oldest threshold (now - 90 days is older than now - 30 days). + * <p> + * Example usage: + * <pre>{@code + * { + * "type": "inline", + * "reindexingDeletionRules": [ + * { + * "id": "remove-bots-90d", + * "olderThan": "P90D", + * "deleteWhere": { + * "type": "not", + * "field": { + * "type": "equals", + * "column": "is_bot", + * "matchValueType": "STRING" + * "matchValue": "true" + * } + * }, + * "description": "Remove bot traffic from segments older than 90 days" + * }, + * { + * "id": "remove-low-priority-180d", + * "olderThan": "P180D", + * "deleteWhere": { + * "type": "not", + * "field": { + * { + * "type": "inType", + * "column": "priority", + * "matchValueType": "STRING", + * "sortedValues": ["low", "spam"] + * } + * } + * }, + * "description": "Remove low-priority data from segments older than 180 days" + * } + * ] + * } + * }</pre> + */ +public class InlineReindexingRuleProvider implements ReindexingRuleProvider +{ + public static final String TYPE = "inline"; + + private final List<ReindexingDeletionRule> reindexingDeletionRules; + private final List<ReindexingMetricsRule> reindexingMetricsRules; + private final List<ReindexingDimensionsRule> reindexingDimensionsRules; + private final List<ReindexingIOConfigRule> reindexingIOConfigRules; + private final List<ReindexingProjectionRule> reindexingProjectionRules; + private final List<ReindexingSegmentGranularityRule> reindexingSegmentGranularityRules; + private final List<ReindexingQueryGranularityRule> reindexingQueryGranularityRules; + private final List<ReindexingTuningConfigRule> reindexingTuningConfigRules; + + + @JsonCreator + public InlineReindexingRuleProvider( + @JsonProperty("reindexingDeletionRules") @Nullable List<ReindexingDeletionRule> reindexingDeletionRules, + @JsonProperty("reindexingMetricsRules") @Nullable List<ReindexingMetricsRule> reindexingMetricsRules, + @JsonProperty("reindexingDimensionsRules") @Nullable List<ReindexingDimensionsRule> reindexingDimensionsRules, + @JsonProperty("reindexingIOConfigRules") @Nullable List<ReindexingIOConfigRule> reindexingIOConfigRules, + @JsonProperty("reindexingProjectionRules") @Nullable List<ReindexingProjectionRule> reindexingProjectionRules, + @JsonProperty("reindexingSegmentGranularityRules") @Nullable List<ReindexingSegmentGranularityRule> reindexingSegmentGranularityRules, + @JsonProperty("reindexingQueryGranularityRules") @Nullable List<ReindexingQueryGranularityRule> reindexingQueryGranularityRules, + @JsonProperty("reindexingTuningConfigRules") @Nullable List<ReindexingTuningConfigRule> reindexingTuningConfigRules + ) Review Comment: ya, seems redundant to have now that you call it out -- 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]
