Package org.egothor.stemmer
Record Class TrieMetadata
java.lang.Object
java.lang.Record
org.egothor.stemmer.TrieMetadata
- Record Components:
formatVersion- persisted binary format version of the trie artifacttraversalDirection- logical key traversal directionreductionSettings- reduction settings used during compilationdiacriticProcessingMode- diacritic processing strategy associated with the artifactcaseProcessingMode- 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 Summary
ConstructorsConstructorDescriptionTrieMetadata(int formatVersion, WordTraversalDirection traversalDirection, ReductionSettings reductionSettings, DiacriticProcessingMode diacriticProcessingMode, CaseProcessingMode caseProcessingMode) Creates a new metadata instance. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecaseProcessingModerecord component.static TrieMetadatacurrent(int formatVersion, WordTraversalDirection traversalDirection, ReductionSettings reductionSettings) Creates metadata populated with current-format defaults for freshly compiled tries.Returns the value of thediacriticProcessingModerecord component.final booleanIndicates whether some other object is "equal to" this one.static TrieMetadataforCompilation(WordTraversalDirection traversalDirection, ReductionSettings reductionSettings, DiacriticProcessingMode diacriticProcessingMode, CaseProcessingMode caseProcessingMode) Creates metadata for a newly compiled trie using the currently persisted binary stream format version.intReturns the value of theformatVersionrecord component.static TrieMetadatafromTextBlock(int formatVersion, String textBlock) Parses metadata from a text block produced bytoTextBlock().final inthashCode()Returns a hash code value for this object.static TrieMetadatalegacy(int formatVersion, WordTraversalDirection traversalDirection) Creates metadata compatible with a legacy artifact version that did not store the full configuration explicitly.Returns the value of thereductionSettingsrecord component.final StringtoString()Returns a string representation of this record class.Returns metadata encoded as a deterministic human-readable text block.Returns the value of thetraversalDirectionrecord component.
-
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 least1traversalDirection- logical key traversal directionreductionSettings- reduction settings used during compilationdiacriticProcessingMode- diacritic processing strategycaseProcessingMode- 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 versiontraversalDirection- logical key traversal directionreductionSettings- 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 directionreductionSettings- reduction settings used during compilationdiacriticProcessingMode- diacritic processing strategycaseProcessingMode- case processing strategy- Returns:
- metadata aligned with the current persisted stream format
-
legacy
Creates metadata compatible with a legacy artifact version that did not store the full configuration explicitly.- Parameters:
formatVersion- legacy persisted binary format versiontraversalDirection- logical key traversal direction reconstructed from the legacy stream- Returns:
- metadata reconstructed with conservative compatibility defaults
-
toTextBlock
Returns metadata encoded as a deterministic human-readable text block.The format intentionally uses plain
key=valuelines so users can inspect metadata quickly from a decompressed trie payload without additional dependencies.- Returns:
- persisted metadata text block
-
fromTextBlock
Parses metadata from a text block produced bytoTextBlock().- Parameters:
formatVersion- persisted binary format versiontextBlock- metadata text block- Returns:
- parsed metadata
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
formatVersion
public int formatVersion()Returns the value of theformatVersionrecord component.- Returns:
- the value of the
formatVersionrecord component
-
traversalDirection
Returns the value of thetraversalDirectionrecord component.- Returns:
- the value of the
traversalDirectionrecord component
-
reductionSettings
Returns the value of thereductionSettingsrecord component.- Returns:
- the value of the
reductionSettingsrecord component
-
diacriticProcessingMode
Returns the value of thediacriticProcessingModerecord component.- Returns:
- the value of the
diacriticProcessingModerecord component
-
caseProcessingMode
Returns the value of thecaseProcessingModerecord component.- Returns:
- the value of the
caseProcessingModerecord component
-