java.lang.Object
io.github.flink.gcp.connector.bigtable.sink.GcRule
All Implemented Interfaces:
Serializable

@Public public final class GcRule extends Object implements Serializable
A garbage-collection rule for a column family the sink creates, mirroring the four rule shapes Bigtable's admin API takes: a version cap, an age cap, and their union and intersection.

This is the sink's own value type rather than the client's GCRules.GCRule because it travels in the job graph: TableCreateOptions is serialized into the sink's configuration, and the client's rule models are not Serializable. The translation happens where the table is created.

A family declared without a rule keeps Bigtable's default of collecting nothing, which for this sink is a decision, not an omission: the sink is at-least-once, a replay writes the same cells again, and the garbage-collection policy is what decides whether those duplicate versions accumulate forever. union(maxVersions(1), maxAge(...)) is the usual shape for keeping only the latest cell.

Validation is shape-only (positivity, arity); nesting depth and any service-side limits are left to Bigtable, whose rejection names what it refused. Instances are immutable.

See Also:
  • Method Details

    • maxVersions

      public static GcRule maxVersions(int maxVersions)
      A rule collecting all but the newest maxVersions versions of a cell.
      Parameters:
      maxVersions - the number of versions to keep, positive
      Returns:
      the rule
    • maxAge

      public static GcRule maxAge(Duration maxAge)
      A rule collecting cells older than maxAge.
      Parameters:
      maxAge - the age past which cells are collected, positive
      Returns:
      the rule
    • union

      public static GcRule union(GcRule... rules)
      A rule collecting cells any of the given rules would collect.
      Parameters:
      rules - the rules to union, at least two
      Returns:
      the rule
    • intersection

      public static GcRule intersection(GcRule... rules)
      A rule collecting only cells every one of the given rules would collect.
      Parameters:
      rules - the rules to intersect, at least two
      Returns:
      the rule
    • getKind

      public GcRule.Kind getKind()
      Returns the rule's shape, deciding which of the other accessors is non-null.
    • getMaxVersions

      @Nullable public Integer getMaxVersions()
      Returns the version cap of a GcRule.Kind.MAX_VERSIONS rule, or null for other kinds.
    • getMaxAge

      @Nullable public Duration getMaxAge()
      Returns the age cap of a GcRule.Kind.MAX_AGE rule, or null for other kinds.
    • getRules

      @Nullable public List<GcRule> getRules()
      Returns the nested rules of a GcRule.Kind.UNION or GcRule.Kind.INTERSECTION rule, or null for the leaf kinds.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object