Class ScyllaTypeMap.Builder
Fluent builder for constructing ScyllaTypeMap instances with complex configurations. Supports type capacity, bucket capacity, fixed-capacity mode, custom type comparer, and synchronized wrapper creation.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class ScyllaTypeMap.Builder
Remarks
The builder provides a discoverable API for configuring type maps without relying on positional parameters. Use Build() to obtain a configured type map (returns interface for synchronized wrappers). Use BuildConcrete() to obtain the concrete unsynchronized type map type (throws if synchronized).
// Basic usage with defaults
var typeMap = ScyllaTypeMap.CreateBuilder().Build();
// Configure type capacity and bucket capacity
var typeMap = ScyllaTypeMap.CreateBuilder()
.WithTypeCapacity(64)
.WithBucketCapacity(16)
.FixedCapacity()
.Build();
// Create synchronized (thread-safe) wrapper
var typeMap = ScyllaTypeMap.CreateBuilder()
.WithTypeCapacity(128)
.WithBucketCapacity(32)
.Synchronized()
.Build();
Methods
Build()
Builds and returns the configured ScyllaTypeMap instance or synchronized wrapper. If Synchronized(object) was called, returns a ScyllaTypeMap.SynchronizedScyllaTypeMap wrapper. Otherwise, returns the unsynchronized ScyllaTypeMap.
Declaration
public IScyllaCollection Build()
Returns
| Type | Description |
|---|---|
| IScyllaCollection | An IScyllaCollection representing either the unsynchronized type map or synchronized wrapper |
BuildConcrete()
Builds and returns the concrete unsynchronized ScyllaTypeMap instance. This method provides access to the concrete type instead of the interface.
Declaration
public ScyllaTypeMap BuildConcrete()
Returns
| Type | Description |
|---|---|
| ScyllaTypeMap | The configured unsynchronized ScyllaTypeMap 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 type table or buckets become full. When fixed-capacity is enabled, operations will return false instead of resizing when capacity limits are reached.
Declaration
public ScyllaTypeMap.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 |
|---|---|
| ScyllaTypeMap.Builder | This builder instance for method chaining |
Synchronized(object)
Configures the builder to return a synchronized (thread-safe) wrapper around the type map. All operations on the synchronized wrapper will be protected by a lock.
Declaration
public ScyllaTypeMap.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 |
|---|---|
| ScyllaTypeMap.Builder | This builder instance for method chaining |
WithBucketCapacity(int)
Sets the default initial capacity for each type bucket (number of IDs that can be stored per type).
Declaration
public ScyllaTypeMap.Builder WithBucketCapacity(int bucketCapacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | bucketCapacity | The default bucket capacity. Must be at least 1. If less than 1, will be clamped to 1 during construction. |
Returns
| Type | Description |
|---|---|
| ScyllaTypeMap.Builder | This builder instance for method chaining |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when bucketCapacity is less than 1 |
WithTypeCapacity(int)
Sets the initial capacity of the type table (number of distinct types that can be stored).
Declaration
public ScyllaTypeMap.Builder WithTypeCapacity(int typeCapacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | typeCapacity | The initial type table capacity. Must be at least 1. If less than 1, will be clamped to 1 during construction. |
Returns
| Type | Description |
|---|---|
| ScyllaTypeMap.Builder | This builder instance for method chaining |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when typeCapacity is less than 1 |
WithTypeComparer(IEqualityComparer<Type>)
Sets a custom equality comparer for Type key comparison. If not set or set to null, the type map will use Default for Type.
Declaration
public ScyllaTypeMap.Builder WithTypeComparer(IEqualityComparer<Type> typeComparer)
Parameters
| Type | Name | Description |
|---|---|---|
| IEqualityComparer<Type> | typeComparer | The equality comparer to use for type key comparison, or null to use the default comparer. |
Returns
| Type | Description |
|---|---|
| ScyllaTypeMap.Builder | This builder instance for method chaining |