Record Class TrieMetadata

java.lang.Object
java.lang.Record
org.egothor.stemmer.TrieMetadata
Record Components:
formatVersion - persisted binary format version of the trie artifact
traversalDirection - logical key traversal direction
reductionSettings - reduction settings used during compilation
diacriticProcessingMode - diacritic processing strategy associated with the artifact
caseProcessingMode - case processing strategy associated with the artifact

public record TrieMetadata(int formatVersion, WordTraversalDirection traversalDirection, ReductionSettings reductionSettings, DiacriticProcessingMode diacriticProcessingMode, CaseProcessingMode caseProcessingMode) extends Record
Immutable metadata persisted together with a compiled trie artifact.

The metadata captures the semantic build configuration required to interpret the compiled trie correctly after it is reloaded. Persisting the metadata as part of the artifact makes the binary format self-describing and avoids coupling runtime consumers to external side-channel configuration.

The record is intentionally extensible. It already models traversal direction, reduction settings, and diacritic processing strategy, even though not every field necessarily influences all current code paths yet.

  • Constructor Details

    • TrieMetadata

      public TrieMetadata(int formatVersion, WordTraversalDirection traversalDirection, ReductionSettings reductionSettings, DiacriticProcessingMode diacriticProcessingMode, CaseProcessingMode caseProcessingMode)
      Creates a new metadata instance.
      Parameters:
      formatVersion - persisted binary format version, must be at least 1
      traversalDirection - logical key traversal direction
      reductionSettings - reduction settings used during compilation
      diacriticProcessingMode - diacritic processing strategy
      caseProcessingMode - case processing strategy
  • Method Details

    • current

      public static TrieMetadata current(int formatVersion, WordTraversalDirection traversalDirection, ReductionSettings reductionSettings)
      Creates metadata populated with current-format defaults for freshly compiled tries.
      Parameters:
      formatVersion - persisted binary format version
      traversalDirection - logical key traversal direction
      reductionSettings - reduction settings used during compilation
      Returns:
      metadata initialized with current defaults
    • forCompilation

      public static TrieMetadata forCompilation(WordTraversalDirection traversalDirection, ReductionSettings reductionSettings, DiacriticProcessingMode diacriticProcessingMode, CaseProcessingMode caseProcessingMode)
      Creates metadata for a newly compiled trie using the currently persisted binary stream format version.
      Parameters:
      traversalDirection - logical key traversal direction
      reductionSettings - reduction settings used during compilation
      diacriticProcessingMode - diacritic processing strategy
      caseProcessingMode - case processing strategy
      Returns:
      metadata aligned with the current persisted stream format
    • legacy

      public static TrieMetadata legacy(int formatVersion, WordTraversalDirection traversalDirection)
      Creates metadata compatible with a legacy artifact version that did not store the full configuration explicitly.
      Parameters:
      formatVersion - legacy persisted binary format version
      traversalDirection - logical key traversal direction reconstructed from the legacy stream
      Returns:
      metadata reconstructed with conservative compatibility defaults
    • toTextBlock

      public String toTextBlock()
      Returns metadata encoded as a deterministic human-readable text block.

      The format intentionally uses plain key=value lines so users can inspect metadata quickly from a decompressed trie payload without additional dependencies.

      Returns:
      persisted metadata text block
    • fromTextBlock

      public static TrieMetadata fromTextBlock(int formatVersion, String textBlock)
      Parses metadata from a text block produced by toTextBlock().
      Parameters:
      formatVersion - persisted binary format version
      textBlock - metadata text block
      Returns:
      parsed metadata
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components 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.
    • formatVersion

      public int formatVersion()
      Returns the value of the formatVersion record component.
      Returns:
      the value of the formatVersion record component
    • traversalDirection

      public WordTraversalDirection traversalDirection()
      Returns the value of the traversalDirection record component.
      Returns:
      the value of the traversalDirection record component
    • reductionSettings

      public ReductionSettings reductionSettings()
      Returns the value of the reductionSettings record component.
      Returns:
      the value of the reductionSettings record component
    • diacriticProcessingMode

      public DiacriticProcessingMode diacriticProcessingMode()
      Returns the value of the diacriticProcessingMode record component.
      Returns:
      the value of the diacriticProcessingMode record component
    • caseProcessingMode

      public CaseProcessingMode caseProcessingMode()
      Returns the value of the caseProcessingMode record component.
      Returns:
      the value of the caseProcessingMode record component