Class FrequencyTrie.Builder<V>
- Type Parameters:
V- value type
- Enclosing class:
FrequencyTrie<V>
FrequencyTrie.
The builder is intentionally mutable and optimized for repeated
put(String, Object) calls. The final trie is created by
build(), which performs bottom-up subtree reduction and converts the
structure to a compact immutable representation optimized for read
operations.
-
Constructor Summary
ConstructorsConstructorDescriptionBuilder(IntFunction<V[]> arrayFactory, ReductionMode reductionMode) Creates a new builder using default thresholds for the supplied reduction mode.Builder(IntFunction<V[]> arrayFactory, ReductionMode reductionMode, WordTraversalDirection traversalDirection) Creates a new builder using default thresholds for the supplied reduction mode and explicit traversal direction.Builder(IntFunction<V[]> arrayFactory, ReductionSettings reductionSettings) Creates a new builder with the provided settings.Builder(IntFunction<V[]> arrayFactory, ReductionSettings reductionSettings, WordTraversalDirection traversalDirection) Creates a new builder with the provided settings and explicit traversal direction.Builder(IntFunction<V[]> arrayFactory, ReductionSettings reductionSettings, WordTraversalDirection traversalDirection, CaseProcessingMode caseProcessingMode) Creates a new builder with the provided settings, explicit traversal direction, and explicit case processing mode.Builder(IntFunction<V[]> arrayFactory, ReductionSettings reductionSettings, WordTraversalDirection traversalDirection, CaseProcessingMode caseProcessingMode, DiacriticProcessingMode diacriticProcessingMode) Creates a new builder with the provided settings, explicit traversal direction, explicit case processing mode, and explicit diacritic processing mode. -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a compiled read-only trie.Stores a value for the supplied key and increments its local frequency.Stores a value for the supplied key and increments its local frequency by the specified positive count.
-
Constructor Details
-
Builder
Creates a new builder with the provided settings.This constructor preserves the historical Egothor behavior and therefore traverses logical keys from their end toward their beginning.
- Parameters:
arrayFactory- array factoryreductionSettings- reduction configuration- Throws:
NullPointerException- if any argument isnull
-
Builder
public Builder(IntFunction<V[]> arrayFactory, ReductionSettings reductionSettings, WordTraversalDirection traversalDirection) Creates a new builder with the provided settings and explicit traversal direction.- Parameters:
arrayFactory- array factoryreductionSettings- reduction configurationtraversalDirection- logical key traversal direction- Throws:
NullPointerException- if any argument isnull
-
Builder
public Builder(IntFunction<V[]> arrayFactory, ReductionSettings reductionSettings, WordTraversalDirection traversalDirection, CaseProcessingMode caseProcessingMode) Creates a new builder with the provided settings, explicit traversal direction, and explicit case processing mode.- Parameters:
arrayFactory- array factoryreductionSettings- reduction configurationtraversalDirection- logical key traversal directioncaseProcessingMode- dictionary case processing mode- Throws:
NullPointerException- if any argument isnull
-
Builder
public Builder(IntFunction<V[]> arrayFactory, ReductionSettings reductionSettings, WordTraversalDirection traversalDirection, CaseProcessingMode caseProcessingMode, DiacriticProcessingMode diacriticProcessingMode) Creates a new builder with the provided settings, explicit traversal direction, explicit case processing mode, and explicit diacritic processing mode.- Parameters:
arrayFactory- array factoryreductionSettings- reduction configurationtraversalDirection- logical key traversal directioncaseProcessingMode- dictionary case processing modediacriticProcessingMode- dictionary diacritic processing mode- Throws:
NullPointerException- if any argument isnull
-
Builder
Creates a new builder using default thresholds for the supplied reduction mode.This constructor preserves the historical Egothor behavior and therefore traverses logical keys from their end toward their beginning.
- Parameters:
arrayFactory- array factoryreductionMode- reduction mode- Throws:
NullPointerException- if any argument isnull
-
Builder
public Builder(IntFunction<V[]> arrayFactory, ReductionMode reductionMode, WordTraversalDirection traversalDirection) Creates a new builder using default thresholds for the supplied reduction mode and explicit traversal direction.- Parameters:
arrayFactory- array factoryreductionMode- reduction modetraversalDirection- logical key traversal direction- Throws:
NullPointerException- if any argument isnull
-
-
Method Details
-
put
Stores a value for the supplied key and increments its local frequency.Values are stored at the node addressed by the full key. Since trie values may also appear on internal nodes, an empty key is valid and stores a value directly at the root.
- Parameters:
key- keyvalue- value- Returns:
- this builder
- Throws:
NullPointerException- ifkeyorvalueisnull
-
build
Builds a compiled read-only trie.- Returns:
- compiled trie
-
put
Stores a value for the supplied key and increments its local frequency by the specified positive count.Values are stored at the node addressed by the full key. Since trie values may also appear on internal nodes, an empty key is valid and stores a value directly at the root.
This method is functionally equivalent to calling
put(String, Object)repeatedlycounttimes, but it avoids unnecessary repeated map updates and is therefore preferable for bulk reconstruction from compiled tries or other aggregated sources.- Parameters:
key- keyvalue- valuecount- positive frequency increment- Returns:
- this builder
- Throws:
NullPointerException- ifkeyorvalueisnullIllegalArgumentException- ifcountis less than1
-