Class AbstractReindexingRule

java.lang.Object
org.apache.druid.server.compaction.AbstractReindexingRule
All Implemented Interfaces:
ReindexingRule
Direct Known Subclasses:
ReindexingDataSchemaRule, ReindexingDeletionRule, ReindexingIndexSpecRule, ReindexingPartitioningRule

public abstract class AbstractReindexingRule extends Object implements ReindexingRule
Base implementation for reindexing rules that apply based on data age thresholds.

Provides period-based applicability logic: a rule with olderThan of P7D applies to data older than 7 days as compared to the time of evaluation. Subclasses define specific reindexing configuration (granularity, filters, tuning, etc.) and whether multiple rules can combine (additive vs non-additive).

The appliesTo(Interval, DateTime) method determines if an interval is fully, partially, or not covered by this rule's threshold, enabling cascading reindexing strategies where different rules apply to different age tiers of data.

  • Constructor Details

    • AbstractReindexingRule

      public AbstractReindexingRule(@Nonnull String id, @Nullable String description, @Nonnull org.joda.time.Period olderThan)
  • Method Details

    • getId

      public String getId()
      Description copied from interface: ReindexingRule
      Provides an identifier for the rule, which can be used for referencing, logging, or management purposes.

      Note that there is no inherent contract for uniqueness across rule sets provided by this interface.

      Specified by:
      getId in interface ReindexingRule
    • getDescription

      public String getDescription()
      Description copied from interface: ReindexingRule
      Provides a human-readable description of the rule, which can be used for logging, debugging, or user interfaces to explain the purpose and behavior of the rule.
      Specified by:
      getDescription in interface ReindexingRule
    • getOlderThan

      public org.joda.time.Period getOlderThan()
      Description copied from interface: ReindexingRule
      Defines the age threshold for rule applicability. The rule applies to data older than a reference time minus this period.

      For example, if the period is "P30D" (30 days) and the reference time is "2024-01-31T00:00:00Z", the rule applies to data older than "2024-01-01T00:00:00Z".

      Specified by:
      getOlderThan in interface ReindexingRule
      Returns:
      The period representing the age threshold for rule applicability.
    • appliesTo

      public ReindexingRule.AppliesToMode appliesTo(org.joda.time.Interval interval, @Nullable org.joda.time.DateTime referenceTime)
      Description copied from interface: ReindexingRule
      Check if this rule applies to the given interval.

      Specified by:
      appliesTo in interface ReindexingRule
      Parameters:
      interval - The interval to check applicability against.
      referenceTime - The reference time to use for period calculations. null results in using current UTC instant at runtime.
      Returns:
      The applicability mode of the rule for the given interval and reference time.