Class S3TreeRewriter

java.lang.Object
software.amazon.smithy.rulesengine.aws.s3.S3TreeRewriter

public final class S3TreeRewriter extends Object
Rewrites S3 endpoint rules to create a dramatically smaller and more efficient BDD.

This is a BDD pre-processing transform that makes the decision tree larger but enables dramatically reduced BDD artifact size. It solves the "SSA Trap" problem where semantically identical operations appear as syntactically different expressions.

This class composes three separate transforms, each selectable via S3TreeRewriter.Transform:

  1. S3TreeRewriter.Transform.AZ_CANONICALIZATION - Canonicalizes AZ extraction: substring(Bucket, N, M)split(Bucket, "--")[1]
  2. S3TreeRewriter.Transform.REGION_UNIFICATION - Unifies region references: Region/bucketArn#region_signing_region/_effective_region
  3. S3TreeRewriter.Transform.S3EXPRESS_ENDPOINTS - Canonicalizes S3Express endpoints: FIPS/DualStack URL variants → ITE-computed segments

By default all transforms are applied. Use transform(EndpointRuleSet, Transform, Transform...) to select a subset.

This transform isn't stable. While it reduces BDD node count and enables much better sharing and reduces the number of unique results, it comes at the expense of runtime performance in many cases due to adding more complex expressions than before. It's possible we may entirely rewrite this to do different transforms, abandon it entirely, or move to a different kind of optimization altogether. In short, don't rely on this class.

  • Method Details

    • transform

      public static EndpointRuleSet transform(EndpointRuleSet ruleSet)
      Transforms the given endpoint rule set by applying the default S3 canonicalization transforms (AZ canonicalization and S3Express endpoints).
      Parameters:
      ruleSet - Rules to transform.
      Returns:
      the transformed rule set.
    • transform

      public static EndpointRuleSet transform(EndpointRuleSet ruleSet, S3TreeRewriter.Transform first, S3TreeRewriter.Transform... rest)
      Transforms the given endpoint rule set by applying only the specified transforms.
      Parameters:
      ruleSet - Rules to transform.
      first - the first transform to apply.
      rest - additional transforms to apply.
      Returns:
      the transformed rule set.