Record Class YamlLimits

java.lang.Object
java.lang.Record
dev.omnist.codec.YamlLimits
Record Components:
maxAliasExpansion - maximum expansion factor of any candidate node (reference default: 50)
maxExpandedSlots - maximum value slots a document containing an alias or merge key materializes (reference default: 1 000 000)

public record YamlLimits(int maxAliasExpansion, long maxExpandedSlots) extends Record
The two YAML alias limits of omnist-spec section 2.4.1: the maximum alias expansion factor (D-18) and the maximum expanded size (D-22).

Both are finite, as D-10 requires, and both are enforced by YamlCodec.readWithLimits(String, YamlLimits) on the composed node graph before anything is materialized (D-19).

maxAliasExpansion is compared against E = W / S of every candidate node: an input is rejected with document.limit.alias-expansion when some E is greater than it, and accepted when it is equal. maxExpandedSlots is compared against W of the document root, only for an input that contains an alias or a merge key: an input is rejected with document.limit.expanded-size when W(root) is greater than it, and accepted when it is equal.

Like Limits, a value that is not positive is refused with IllegalArgumentException rather than quietly replaced by the default. A value above the ceiling is refused too: maxAliasExpansion at most 10000, maxExpandedSlots at most 10000000L (the ceiling the spec recommends for D-22; it measured about 780 bytes per slot in Go, so past it the cap no longer bounds memory on a typical heap).

  • Field Details

    • DEFAULT_MAX_ALIAS_EXPANSION

      public static final int DEFAULT_MAX_ALIAS_EXPANSION
      Reference default for the maximum alias expansion factor (D-18).
      See Also:
    • DEFAULT_MAX_EXPANDED_SLOTS

      public static final long DEFAULT_MAX_EXPANDED_SLOTS
      Reference default for the maximum expanded size in value slots (D-22).
      See Also:
    • MAX_ALIAS_EXPANSION_CEILING

      public static final int MAX_ALIAS_EXPANSION_CEILING
      Largest accepted maxAliasExpansion.
      See Also:
    • MAX_EXPANDED_SLOTS_CEILING

      public static final long MAX_EXPANDED_SLOTS_CEILING
      Largest accepted maxExpandedSlots: the ceiling omnist-spec D-22 recommends.
      See Also:
    • DEFAULT

      public static final YamlLimits DEFAULT
      The reference defaults.
  • Constructor Details

    • YamlLimits

      public YamlLimits(int maxAliasExpansion, long maxExpandedSlots)
      Creates an instance of a YamlLimits record class.
      Parameters:
      maxAliasExpansion - the value for the maxAliasExpansion record component
      maxExpandedSlots - the value for the maxExpandedSlots record component
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • maxAliasExpansion

      public int maxAliasExpansion()
      Returns the value of the maxAliasExpansion record component.
      Returns:
      the value of the maxAliasExpansion record component
    • maxExpandedSlots

      public long maxExpandedSlots()
      Returns the value of the maxExpandedSlots record component.
      Returns:
      the value of the maxExpandedSlots record component