Trait LayerKey

Source
pub trait LayerKey: Clone {
    // Provided methods
    fn merge_type(&self) -> MergeType { ... }
    fn next_key(&self) -> Option<Self> { ... }
    fn search_key(&self) -> Self { ... }
}
Expand description

Determines how to iterate forward from the current key, and how many older layers to include when merging. See the different variants of MergeKeyType for more details.

Provided Methods§

Source

fn merge_type(&self) -> MergeType

Called to determine how to perform merge behaviours while advancing through a layer set.

Source

fn next_key(&self) -> Option<Self>

The next_key() call allows for an optimisation which allows the merger to avoid querying a layer if it knows it has found the next possible key. It only makes sense for this to return Some() when merge_type() returns OptimizedMerge. Consider the following example showing two layers with range based keys.

 +----------+------------+

0 | 0..100 | 100..200 | +–––––+————+ 1 | 100..200 | +————+

If you search and find the 0..100 key, then only layer 0 will be touched. If you then want to advance to the 100..200 record, you can find it in layer 0 but unless you know that it immediately follows the 0..100 key i.e. that there is no possible key, K, such that 0..100 < K < 100..200, the merger has to consult all other layers to check. next_key should return a key, N, such that if the merger encounters a key that is <= N (using OrdLowerBound), it can stop touching more layers. The key N should also be the the key to search for in other layers if the merger needs to do so. In the example above, it should be a key that is > 0..100 and 99..100, but <= 100..200 (using OrdUpperBound). In practice, what this means is that for range based keys, OrdUpperBound should use the end of the range, OrdLowerBound should use the start of the range, and next_key should return end..end + 1. This is purely an optimisation; the default None will be correct but not performant.

Source

fn search_key(&self) -> Self

Returns the search key for this extent; that is, a key which is <= this key under Ord and OrdLowerBound. Note that this is only used for Query::LimitedRange queries (where Self::partition returns Some). For example, if the tree has extents 50..150 and 150..200 and we wish to read 100..200, we’d search for 0..101 which would set the iterator to 50..150.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§