Abstract base class for persistent dictionaries that use a block-based index data structure (B-Tree) for efficiency.
class
|
BlockIndex
|
with
|
<TKey>
|
||
<TValue>
|
|||||
extends
|
BlockIndexBase
|
||||
base of
|
SimpleBlockIndex
|
Does this object support read access?
public
property
|
CanRead
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
this
object
supports
reading,
false
if
not. |
||
inherited
|
BlockIndexBase.CanRead
|
Does this binary object support write access?
public
property
|
CanWrite
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
this
object
supports
writing,
false
if
not. |
||
inherited
|
BlockIndexBase.CanWrite
|
Checks if this block index is empty (i.e. has no entries at all).
[BeginEnd]
|
||||
public
property
|
IsEmpty
{
get
}
|
|||
type
|
bool
|
|||
value
|
true
if
the
index
is
empty,
false
if
there
is
at
least
one
entry.
|
Returns the lifecycle state of this object.
public
virtual
property
|
LifecycleState
{
get
}
|
||
type
|
LifecycleState
|
||
value
|
The lifecycle state. | ||
inherited
|
Disposable.LifecycleState
|
Returns the maximum entry key in the index.
[BeginEnd]
|
||||
public
property
|
MaximumKey
{
get
}
|
|||
type
|
TKey
|
|||
value
|
The maximum entry key. |
Returns the maximum entry value in the index.
[BeginEnd]
|
||||
public
property
|
MaximumValue
{
get
}
|
|||
type
|
TValue
|
|||
value
|
The maximum entry value. |
Returns the minimum entry key in the index.
[BeginEnd]
|
||||
public
property
|
MinimumKey
{
get
}
|
|||
type
|
TKey
|
|||
value
|
The minimum entry key. |
Returns the minimum entry value in the index.
[BeginEnd]
|
||||
public
property
|
MinimumValue
{
get
}
|
|||
type
|
TValue
|
|||
value
|
The minimum entry value. |
Returns a Path object that represents the file path this object is associated with.
public
property
|
PathInfo
{
get
}
|
||
type
|
Path
|
||
value
|
|
The path info. | |
inherited
|
BlockIndexBase.PathInfo
|
Remarks:
Objects that do not have a meaningful file path association simply return Unknown.
Creates a new block index in the given block storage.
public
static
method
|
Create
(BlockStorage storage,
IBlockIndexOrder<TKey, TValue> order,
IBlockIndexFormat<TValue> format,
BlockIdSlot root)
|
||
type
|
BlockIndex<TKey, TValue>
|
||
params
|
storage
|
[not-null]
|
The persistent block storage. |
order
|
[not-null]
|
The block index sort order handler. | |
format
|
[not-null]
|
The block index binary format handler. | |
root
|
The block index root storage location. | ||
returns
|
|
The created BlockIndex object. |
Remarks:
The returned block index belongs to storage and will be disposed with it.
Creates a new block index in the given block storage.
public
static
method
|
New
(bool create,
BlockStorage storage,
IBlockIndexOrder<TKey, TValue> order,
IBlockIndexFormat<TValue> format,
BlockIdSlot root)
|
||
type
|
BlockIndex<TKey, TValue>
|
||
params
|
create
|
Create a new block index or open an existing one? | |
storage
|
[not-null]
|
The persistent block storage. | |
order
|
[not-null]
|
The block index sort order handler. | |
format
|
[not-null]
|
The block index binary format handler. | |
root
|
The block index root storage location. | ||
returns
|
|
The created BlockIndex object. |
Remarks:
The returned block index belongs to storage and will be disposed with it.
Opens an existing block index in the given block storage.
public
static
method
|
Open
(BlockStorage storage,
IBlockIndexOrder<TKey, TValue> order,
IBlockIndexFormat<TValue> format,
BlockIdSlot root)
|
||
type
|
BlockIndex<TKey, TValue>
|
||
params
|
storage
|
[not-null]
|
The persistent block storage. |
order
|
[not-null]
|
The block index sort order handler. | |
format
|
[not-null]
|
The block index binary format handler. | |
root
|
The block index root storage location. | ||
returns
|
|
The opened BlockIndex object. |
Remarks:
The returned block index belong to storage and will be disposed with it.
Acquires a strong reference to this disposable object.
[OwnerReturn, ThreadSafe]
|
||||
public
method
|
AcquireTry
()
|
|||
type
|
IDisposable
|
|||
returns
|
this
if
a
new
strong
reference
has
been
acquired,
null
if
this
object
is
already
being
disposed.
|
|||
inherited
|
Disposable.AcquireTry
|
Remarks:
The object will not be actually disposed by calls to Dispose when there is at least one strong reference left. Code that calls the AcquireTry method is responsible for calling the Dispose method accordingly.
This method is not intended to be used in performance-critical code. It should only be used to high-level resource management.
Clears all data from this block index.
[BeginWriteEnd]
|
||||
public
override
sealed
method
|
Clear
()
|
|||
implements
|
BlockIndexBase.Clear
|
Deletes an entry from the block tree.
[BeginWriteEnd]
|
||||
public
method
|
DeleteKey
(TKey key)
|
|||
params
|
key
|
Key of the entry to delete. |
Remarks:
If no entry exists for the given key, the method silently returns.
Deletes an entry from the block tree.
[BeginWriteEnd]
|
||||
public
method
|
DeleteValue
(TValue value)
|
|||
params
|
value
|
Value of the entry to delete. |
Remarks:
If no entry exists for the given key, the method silently returns.
Releases all resources held by this object if there are no more strong references to it, decrements the reference counter by one otherwise.
[Dispose, OwnerThis, ThreadSafe]
|
||||
public
method
|
Dispose
()
|
|||
inherited
|
Disposable.Dispose
|
Remarks:
The Dispose method silently returns if the object has already been disposed.
Tries to find an entry in the block tree.
[BeginEnd]
|
||||
public
method
|
Find
(TKey key,
TValue defaultValue = default(TValue))
|
|||
type
|
TValue
|
|||
params
|
key
|
Key of the entry to find. | ||
defaultValue
|
Default value to return if no entry exists for key. | |||
returns
|
The value of the found entry or defaultValue if not found. |
Finds all entries.
[BeginEnd]
|
||||
public
method
|
FindAll
(CollectorDelegate<TValue> result = null)
|
|||
type
|
int32
|
|||
params
|
result
|
Optional
collector
for
found
entries.
Defaults
to
null . |
||
returns
|
|
Number of entries. |
Finds all entries starting at the given key.
[BeginEnd]
|
||||
public
method
|
FindFrom
(TKey from,
bool fromIncluded,
CollectorDelegate<TValue> result = null)
|
|||
type
|
int32
|
|||
params
|
from
|
The first key to find. | ||
fromIncluded
|
Return from as a result? | |||
result
|
Optional collector for found entries. | |||
returns
|
|
Number of found entries. |
Finds all entries that are included in the given key range.
[BeginEnd]
|
||||
public
method
|
FindFromTo
(TKey from,
bool fromIncluded,
TKey to,
bool toIncluded,
CollectorDelegate<TValue> result = null)
|
|||
type
|
int32
|
|||
params
|
from
|
The first key to find. | ||
fromIncluded
|
Return from as a result? | |||
to
|
The last key to find. | |||
toIncluded
|
Return to as a result? | |||
result
|
Optional collector for found entries. | |||
returns
|
|
Number of found entries. |
Tries to find an entry in the block tree.
[BeginEnd]
|
||||
public
method
|
FindMaximum
(TKey upper,
TValue defaultValue = default(TValue))
|
|||
type
|
TValue
|
|||
params
|
upper
|
The upper bound for entry key values (inclusive). | ||
defaultValue
|
Default value to return if no entry is found. | |||
returns
|
The found entry or defaultValue if not found. |
Remarks:
All entries that have keys less than or equal to the given upper bound are included in the search. From all included entries, the one with the biggest key value is returned.
Tries to find an entry in the block tree.
[BeginEnd]
|
||||
public
method
|
FindMinimum
(TKey lower,
TValue defaultValue = default(TValue))
|
|||
type
|
TValue
|
|||
params
|
lower
|
The lower bound for entry key values (inclusive). | ||
defaultValue
|
Default value to return if no entry is found. | |||
returns
|
The value of the entry or defaultValue if not found. |
Remarks:
All entries that have keys greater than or equal to the given lower bound are included in the search. From all included entries, the one with the smallest key value is returned.
Finds all entries up to the given key.
[BeginEnd]
|
||||
public
method
|
FindTo
(TKey to,
bool toIncluded,
CollectorDelegate<TValue> result = null)
|
|||
type
|
int32
|
|||
params
|
to
|
The last key to find. | ||
toIncluded
|
Return to as a result? | |||
result
|
Optional collector for found entries. | |||
returns
|
|
Number of found entries. |
Inserts or updates an entry in the block tree.
[BeginWriteEnd]
|
||||
public
method
|
Insert
(TValue value)
|
|||
params
|
value
|
Value of the entry to insert or update. |
Remarks:
If an entry already exists for the given value, it will be updated. If no entry exists, a new one will be inserted into the index.
The pool for data streams (block node I/O).
[Owner]
|
||||
protected
field
|
pool
|
|||
type
|
ObjectPool<MemoryDataStream>
|
|||
inherited
|
BlockIndexBase.pool
|
Disposes the managed resources held by a concrete subclass. This method will be called at most once per subclass.
protected
override
method
|
DisposeManaged
()
|
||
overrides
|
BlockIndexBase.DisposeManaged
|
Remarks:
This method will only be called when a disposable object is explicitly destroyed by user code calling the Dispose method. It will not be called when the object is collected as garbage by the system.
Overriding methods must call the DisposeManaged method of their base class. The base call should be the last statement.
The DisposeManaged method is called before the DisposeUnmanaged method.
Disposes the unmanaged resources held by a concrete subclass. This method will be called exactly once per subclass.
protected
virtual
method
|
DisposeUnmanaged
()
|
||
inherited
|
Disposable.DisposeUnmanaged
|
Remarks:
Overriding methods must call the DisposeUnmanaged method of their base class. The base call should be the last statement.
The DisposeUnmanaged method is called after the DisposeManaged method.