Class HashSetSerializer<T>
Type serializer for HashSet<T> collections. Serializes the set as a JSON
array token sequence (start-array, elements, end-array), or as a null token when the set
reference itself is null. Iteration order follows the set's internal enumerator,
which is unspecified.
Inherited Members
Namespace: Scylla.Core.Util.Serialization
Assembly: ScyllaCore.dll
Syntax
public sealed class HashSetSerializer<T> : TypeSerializerBase<HashSet<T>>, ITypeSerializer<HashSet<T>>, ITypeSerializer
Type Parameters
| Name | Description |
|---|---|
| T | The element type of the set. Element serialization is handled either by the explicitly supplied ITypeSerializer or by dynamic dispatch through SerializationEngine. |
Remarks
Comma handling between JSON elements is delegated to SkipComma() when the active reader is a ScyllaJSONReader.
Constructors
HashSetSerializer(ITypeSerializer)
Creates a HashSet serializer that uses the specified serializer for each element.
Declaration
public HashSetSerializer(ITypeSerializer elementSerializer)
Parameters
| Type | Name | Description |
|---|---|---|
| ITypeSerializer | elementSerializer | The non-generic serializer to use for every set element, or |
Methods
Read(IScyllaReader, ISerializationContext)
Reads a HashSet<T> from the reader.
Returns null when the next token is a null literal; otherwise reads all elements
from the array token sequence into a new HashSet<T> and returns it.
Duplicate elements in the serialized data are silently ignored (the last occurrence wins
if the element is mutable, though for immutable keys the set simply retains the first).
Declaration
public override HashSet<T> Read(IScyllaReader reader, ISerializationContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| IScyllaReader | reader | The reader positioned at the start of an array token sequence or a null token.
Never |
| ISerializationContext | context | The active serialization context. Never |
Returns
| Type | Description |
|---|---|
| HashSet<T> | The deserialized set, or |
Overrides
Write(HashSet<T>, IScyllaWriter, ISerializationContext)
Writes a HashSet<T> to the output.
Emits a null token if value is null; otherwise emits a
JSON array containing all elements serialized in the set's iteration order.
Declaration
public override void Write(HashSet<T> value, IScyllaWriter writer, ISerializationContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| HashSet<T> | value | The set to serialize, or |
| IScyllaWriter | writer | The writer that receives the serialized output. Never |
| ISerializationContext | context | The active serialization context. Never |