Class CelReferenceContinuePredicate<O extends org.apache.polaris.persistence.nosql.api.obj.BaseCommitObj>

java.lang.Object
org.apache.polaris.maintenance.cel.CelReferenceContinuePredicate<O>
All Implemented Interfaces:
Predicate<O>

public class CelReferenceContinuePredicate<O extends org.apache.polaris.persistence.nosql.api.obj.BaseCommitObj> extends Object implements Predicate<O>
Provides a CEL script based "retain reference commit object" predicate used for RetainCollector.refRetain*() functions.

The predicate is coded as a CEL script, using cel-java.

Micro benchmarks prove that the CEL scripts execute pretty fast, definitely fast enough to justify the flexibility of having scripts in the configuration.

The scripts have access to the following declared values:

  • "ref" (string) name of the reference
  • "commits" (64-bit int) number of the currently processed commit, starting at 1
  • "ageDays" (64-bit int) age of currently processed commit in days
  • "ageHours" (64-bit int) age of currently processed commit in hours
  • "ageMinutes" (64-bit int) age of currently processed commit in minutes

Scripts must return a boolean yielding whether the commit shall be retained. Note that maintenance-service implementations can keep the first not-to-be-retained commit.

Example scripts

  • ageDays < 30 || commits <= 10 retains the reference history with at least 10 commits and commits that are younger than 30 days
  • true retains the whole reference history
  • false retains the most recent commit

A static cache retains up to 100 compiled CEL scripts, each up to 24 hours after its last use.

  • Constructor Details

    • CelReferenceContinuePredicate

      public CelReferenceContinuePredicate(@Nonnull String refName, @Nonnull org.apache.polaris.persistence.nosql.api.Persistence persistence, @Nonnull String script)
    • CelReferenceContinuePredicate

      public CelReferenceContinuePredicate(@Nonnull String refName, @Nonnull Function<O,Duration> objAge, @Nonnull String script)
  • Method Details

    • test

      public boolean test(O o)
      Specified by:
      test in interface Predicate<O extends org.apache.polaris.persistence.nosql.api.obj.BaseCommitObj>