Class ScyllaTrie.Builder
Fluent builder for constructing ScyllaTrie instances with complex configurations. Supports node capacity, fixed-capacity mode, case-insensitive matching, and synchronized wrapper creation.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class ScyllaTrie.Builder
Remarks
The builder provides a discoverable API for configuring tries without relying on positional parameters. Use Build() to obtain a configured trie (returns interface for synchronized wrappers). Use BuildConcrete() to obtain the concrete unsynchronized trie type (throws if synchronized).
// Basic usage with defaults
var trie = ScyllaTrie.CreateBuilder().Build();
// Configure node capacity and case-insensitive matching
var trie = ScyllaTrie.CreateBuilder()
.WithNodeCapacity(64)
.IgnoreCase()
.Build();
// Create synchronized (thread-safe) wrapper
var trie = ScyllaTrie.CreateBuilder()
.WithNodeCapacity(128)
.FixedCapacity()
.Synchronized()
.Build();
Methods
Build()
Builds and returns the configured ScyllaTrie instance or synchronized wrapper. If Synchronized(object) was called, returns a ScyllaTrie.SynchronizedScyllaTrie wrapper. Otherwise, returns the unsynchronized ScyllaTrie.
Declaration
public IScyllaTrie Build()
Returns
| Type | Description |
|---|---|
| IScyllaTrie | An IScyllaTrie representing either the unsynchronized trie or synchronized wrapper |
BuildConcrete()
Builds and returns the concrete unsynchronized ScyllaTrie instance. This method provides access to the concrete type instead of the interface.
Declaration
public ScyllaTrie BuildConcrete()
Returns
| Type | Description |
|---|---|
| ScyllaTrie | The configured unsynchronized ScyllaTrie instance |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when Synchronized(object) was called. Use Build() to obtain the synchronized wrapper. |
FixedCapacity(bool)
Enables fixed-capacity mode, preventing automatic growth when the trie becomes full. When fixed-capacity is enabled, insertion operations will return false instead of resizing.
Declaration
public ScyllaTrie.Builder FixedCapacity(bool value = true)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | True to enable fixed-capacity mode, false to allow automatic growth (default: true) |
Returns
| Type | Description |
|---|---|
| ScyllaTrie.Builder | This builder instance for method chaining |
IgnoreCase(bool)
Enables case-insensitive matching using ToUpperInvariant(char) for character comparison. When enabled, keys are compared ignoring case differences.
Declaration
public ScyllaTrie.Builder IgnoreCase(bool value = true)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | True to enable case-insensitive matching, false for case-sensitive (default: true) |
Returns
| Type | Description |
|---|---|
| ScyllaTrie.Builder | This builder instance for method chaining |
Synchronized(object)
Configures the builder to return a synchronized (thread-safe) wrapper around the trie. All operations on the synchronized wrapper will be protected by a lock.
Declaration
public ScyllaTrie.Builder Synchronized(object syncRoot = null)
Parameters
| Type | Name | Description |
|---|---|---|
| object | syncRoot | Optional external lock object to use for synchronization. If null, the wrapper creates and owns a private lock. Provide a custom sync root to coordinate synchronization across multiple synchronized collections. |
Returns
| Type | Description |
|---|---|
| ScyllaTrie.Builder | This builder instance for method chaining |
WithNodeCapacity(int)
Sets the initial capacity of the trie node array.
Declaration
public ScyllaTrie.Builder WithNodeCapacity(int nodeCapacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | nodeCapacity | The initial node capacity. Must be at least 1. If less than 1, will be clamped to 1 during construction. |
Returns
| Type | Description |
|---|---|
| ScyllaTrie.Builder | This builder instance for method chaining |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when nodeCapacity is less than 1 |