Interface IZoneTreeMaintenance<TKey, TValue>
The interface for the maintenance of a ZoneTree.
Namespace: Tenray.ZoneTree
Assembly: ZoneTree.dll
Syntax
public interface IZoneTreeMaintenance<TKey, TValue>
Type Parameters
Name | Description |
---|---|
TKey | The key type |
TValue | The value type |
Properties
| Improve this Doc View SourceBottomSegments
Gets current bottom segments.
Declaration
IReadOnlyList<IDiskSegment<TKey, TValue>> BottomSegments { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<IDiskSegment<TKey, TValue>> |
DiskSegment
Gets current disk segment.
Declaration
IDiskSegment<TKey, TValue> DiskSegment { get; }
Property Value
Type | Description |
---|---|
IDiskSegment<TKey, TValue> |
InMemoryRecordCount
Retrieves the total number of records that lies in memory excluding the sparse array records of DiskSegment. In an LSM tree, records can be duplicated across different segments.
Declaration
long InMemoryRecordCount { get; }
Property Value
Type | Description |
---|---|
long |
IsBottomSegmentsMerging
true if bottom segments merge operation is running, otherwise false.
Declaration
bool IsBottomSegmentsMerging { get; }
Property Value
Type | Description |
---|---|
bool |
IsMerging
true if merge operation is running, otherwise false.
Declaration
bool IsMerging { get; }
Property Value
Type | Description |
---|---|
bool |
MutableSegment
Gets current mutable segment. Mutable segment is the only writable part of the LSM tree.
Declaration
IMutableSegment<TKey, TValue> MutableSegment { get; }
Property Value
Type | Description |
---|---|
IMutableSegment<TKey, TValue> |
MutableSegmentRecordCount
Retrieves the number of records in mutable segment.
Declaration
long MutableSegmentRecordCount { get; }
Property Value
Type | Description |
---|---|
long |
ReadOnlySegments
Gets current readonly segments in-memory. MoveMutableSegmentForward operation moves writable segment to the read-only segments layer. The readonly segments remains in memory until merge operation done.
Declaration
IReadOnlyList<IReadOnlySegment<TKey, TValue>> ReadOnlySegments { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<IReadOnlySegment<TKey, TValue>> |
ReadOnlySegmentsCount
Retrieves the number of read only segments.
Declaration
int ReadOnlySegmentsCount { get; }
Property Value
Type | Description |
---|---|
int |
ReadOnlySegmentsRecordCount
Retrieves the number of records in read-only segments.
Declaration
long ReadOnlySegmentsRecordCount { get; }
Property Value
Type | Description |
---|---|
long |
TotalRecordCount
Retrieves the total number of records that lies in memory and disk excluding the sparse array records of DiskSegments. In an LSM tree, records can be duplicated across different segments. Hence, this is not the actual unique record count of the tree. To get exact record count, a partial database scan is needed. Use Count() and CountFullScan() for actual record count.
Declaration
long TotalRecordCount { get; }
Property Value
Type | Description |
---|---|
long |
Methods
| Improve this Doc View SourceDestroyTree()
Destroys the tree, deletes entire data and WAL store or folder.
Declaration
void DestroyTree()
MoveMutableSegmentForward()
Moves mutable segment into readonly segment. This will clear the writable region of the LSM tree. This method is thread safe and can be called from many threads.
Declaration
void MoveMutableSegmentForward()
ReleaseCircularKeyCacheRecords()
Releases expired circular cache key records.
Declaration
int ReleaseCircularKeyCacheRecords()
Returns
Type | Description |
---|---|
int | The total number of released cached records. |
ReleaseCircularValueCacheRecords()
Releases expired circular cache value records.
Declaration
int ReleaseCircularValueCacheRecords()
Returns
Type | Description |
---|---|
int | The total number of released cached records. |
ReleaseReadBuffers(long)
Releases internal read buffers that have not been used since the specified tick count.
Declaration
int ReleaseReadBuffers(long ticks)
Parameters
Type | Name | Description |
---|---|---|
long | ticks |
Returns
Type | Description |
---|---|
int | The total number of released read buffers. |
SaveMetaData()
Saves tree meta data and clears the meta wal record. After calling this method, the JSON meta file contains up to date tree meta data.
Saving meta file helps following:
- Reduce the size of meta wal file.
- Make Json meta file up to date to analyze parts of the LSM tree. Because Meta WAL file is not human readable.
It is up to user to decide when and how frequently save the meta file.
Declaration
void SaveMetaData()
StartBottomSegmentsMergeOperation(int, int)
Merges selected bottom segments into a single bottom disk segment.
Declaration
Thread StartBottomSegmentsMergeOperation(int fromIndex, int toIndex)
Parameters
Type | Name | Description |
---|---|---|
int | fromIndex | The lower bound |
int | toIndex | The upper bound |
Returns
Type | Description |
---|---|
Thread |
StartMergeOperation()
Merges available in-memory read-only segments to the disk segment.
Declaration
Thread StartMergeOperation()
Returns
Type | Description |
---|---|
Thread |
TryCancelBottomSegmentsMergeOperation()
Attempts to cancel bottom segments merge operation.
Declaration
void TryCancelBottomSegmentsMergeOperation()
TryCancelMergeOperation()
Attempts to cancel merge operation.
Declaration
void TryCancelMergeOperation()
Events
| Improve this Doc View SourceOnBottomSegmentsMergeOperationEnded
Event is fired when bottom segments merge operation is completed.
Declaration
event BottomSegmentsMergeOperationEnded<TKey, TValue> OnBottomSegmentsMergeOperationEnded
Event Type
Type | Description |
---|---|
BottomSegmentsMergeOperationEnded<TKey, TValue> |
OnBottomSegmentsMergeOperationStarted
Event is fired when bottom segments merge operation is completed.
Declaration
event BottomSegmentsMergeOperationStarted<TKey, TValue> OnBottomSegmentsMergeOperationStarted
Event Type
Type | Description |
---|---|
BottomSegmentsMergeOperationStarted<TKey, TValue> |
OnCanNotDropDiskSegment
Event is fired when a disk segment cannot be dropped. This does not harm the database consistency. The cleanup task can be done later.
Declaration
event CanNotDropDiskSegment<TKey, TValue> OnCanNotDropDiskSegment
Event Type
Type | Description |
---|---|
CanNotDropDiskSegment<TKey, TValue> |
OnCanNotDropDiskSegmentCreator
Event is fired when a disk segment creator cannot be dropped. This does not harm the database consistency. The cleanup task can be done later.
Declaration
event CanNotDropDiskSegmentCreator<TKey, TValue> OnCanNotDropDiskSegmentCreator
Event Type
Type | Description |
---|---|
CanNotDropDiskSegmentCreator<TKey, TValue> |
OnCanNotDropReadOnlySegment
Event is fired when a write ahead log cannot be dropped. This does not harm the database consistency. The cleanup task can be done later.
Declaration
event CanNotDropReadOnlySegment<TKey, TValue> OnCanNotDropReadOnlySegment
Event Type
Type | Description |
---|---|
CanNotDropReadOnlySegment<TKey, TValue> |
OnDiskSegmentActivated
Event is fired when the new disk segment is activated.
Declaration
event DiskSegmentCreated<TKey, TValue> OnDiskSegmentActivated
Event Type
Type | Description |
---|---|
DiskSegmentCreated<TKey, TValue> |
OnDiskSegmentCreated
Event is fired when the new disk segment is created. This is the best moment to initialize a sparse array. SparseArray is an in memory array that reduces disk reads. It is the best practice to call DiskSegment.InitSparseArray() when this event is fired.
Declaration
event DiskSegmentCreated<TKey, TValue> OnDiskSegmentCreated
Event Type
Type | Description |
---|---|
DiskSegmentCreated<TKey, TValue> |
OnMergeOperationEnded
Event is fired when merge operation is completed.
Declaration
event MergeOperationEnded<TKey, TValue> OnMergeOperationEnded
Event Type
Type | Description |
---|---|
MergeOperationEnded<TKey, TValue> |
OnMergeOperationStarted
Event is fired when merge operation is started.
Declaration
event MergeOperationStarted<TKey, TValue> OnMergeOperationStarted
Event Type
Type | Description |
---|---|
MergeOperationStarted<TKey, TValue> |
OnMutableSegmentMovedForward
Event is fired when mutable segment is moved forward.
Declaration
event MutableSegmentMovedForward<TKey, TValue> OnMutableSegmentMovedForward
Event Type
Type | Description |
---|---|
MutableSegmentMovedForward<TKey, TValue> |
OnZoneTreeIsDisposing
Event is fired when the ZoneTree is disposing.
Declaration
event ZoneTreeIsDisposing<TKey, TValue> OnZoneTreeIsDisposing
Event Type
Type | Description |
---|---|
ZoneTreeIsDisposing<TKey, TValue> |