Class AATreeRecordStore
- Namespace
- BelNytheraSeiche.TrieDictionary
- Assembly
- BelNytheraSeiche.TrieDictionary.dll
A concrete implementation of BinaryTreeRecordStore that uses a self-balancing AA tree.
public sealed class AATreeRecordStore : BinaryTreeRecordStore, ICloneable
- Inheritance
-
AATreeRecordStore
- Implements
- Inherited Members
Remarks
This class uses an AA tree, a variation of a Red-Black tree, to maintain balance. It simplifies the rebalancing logic by using two core operations, Skew and Split, to handle insertions and deletions efficiently.
Serialization Limits: The binary serialization format for this class imposes certain constraints on the data. Exceeding these limits will result in an InvalidDataException during serialization.
- Max Records per List: A single identifier can have a maximum of 16,777,215 records in its linked list.
- Max Record Content Size: The
Content
byte array of any single record cannot exceed 65,535 bytes.
Methods
Clone()
Creates a deep copy of the AATreeRecordStore.
public object Clone()
Returns
- object
A new AATreeRecordStore instance with the same structure and record data as the original.
Remarks
The method creates a new tree and copies all records, ensuring that the new store is independent of the original.
Deserialize(Stream)
Deserializes an AATreeRecordStore from a stream.
public static AATreeRecordStore Deserialize(Stream stream)
Parameters
stream
StreamThe stream to read the serialized data from.
Returns
- AATreeRecordStore
A new instance of AATreeRecordStore reconstructed from the stream.
Exceptions
- ArgumentNullException
stream
is null.- InvalidDataException
The stream data is corrupted, in an unsupported format, or contains invalid values.
IsBalanced()
Overrides the base method to check if the tree conforms to the specific balancing rules of an AA tree.
public override bool IsBalanced()
Returns
- bool
true if the tree satisfies all tree invariants; otherwise, false.
Remarks
This method validates the level-based properties that define a valid tree.
Remove(int)
Removes the node with the specified identifier from the tree, performing rebalancing operations as necessary.
public override void Remove(int identifier)
Parameters
identifier
intThe identifier of the node to remove.
Exceptions
- ArgumentOutOfRangeException
identifier
is MinValue.
Serialize(AATreeRecordStore, Stream, SerializationOptions?)
Serializes the entire state of the tree store into a stream.
public static void Serialize(AATreeRecordStore store, Stream stream, BasicRecordStore.SerializationOptions? options = null)
Parameters
store
AATreeRecordStoreThe AATreeRecordStore instance to serialize.
stream
StreamThe stream to write the serialized data to.
options
BasicRecordStore.SerializationOptionsOptions to control the serialization process. If null, the settings from Default will be used.
Remarks
The serialization format is specific to this tree implementation, using Brotli compression and an XxHash32 checksum for data integrity.
Exceptions
- ArgumentNullException
store
orstream
is null.