armdb 0.11.0

sharded bitcask key-value storage optimized for NVMe
Documentation
//! Typed prefixes, ranges, and cursor pagination over [`OrderedScan`].
mod builder;
mod bulk;
mod chunked;
mod iters;
pub(crate) mod key_math;
mod merge;
mod scan;

#[cfg(all(test, feature = "typed-tree"))]
mod tests;

use crate::key::Key;
use crate::map_index::Dir;

pub use builder::{MappedPage, Scope};
pub use bulk::Progress;
pub use chunked::{ChunkedPage, PageSpec, StopReason, page_chunks};
pub(crate) use iters::DirRangeIter;
// The `OrderedScan::Iter`/`KeyIter` associated types resolve to these wrappers, so
// they are re-exported from the crate root — a returned iterator must be nameable.
pub use iters::{ConstMapKeyIter, ConstMapRowIter, ConstTreeKeyIter, ConstTreeRowIter};
#[cfg(feature = "fjall")]
pub use iters::{LsmKeyIter, LsmRowIter};
#[cfg(feature = "typed-tree")]
pub use iters::{
    MapKeyIter, MapRowIter, TreeKeyIter, TreeRowIter, ZeroMapKeyIter, ZeroMapRowIter,
    ZeroTreeKeyIter, ZeroTreeRowIter,
};
#[cfg(feature = "var-collections")]
pub use iters::{VarMapKeyIter, VarMapRowIter, VarTreeKeyIter, VarTreeRowIter};
#[cfg(all(feature = "typed-tree", feature = "var-collections"))]
pub use iters::{VarTypedMapKeyIter, VarTypedMapRowIter, VarTypedTreeKeyIter, VarTypedTreeRowIter};
pub use merge::{BoxedRows, CoalescedMerge, MergeSorted, boxed, merge_sorted};
pub use scan::{BulkScan, MapScan, OrderedScan, OwnedRows, StrictRows, TreeScan};

/// Build a [`Scope`] over a tree or LSM collection.
pub(crate) fn tree_scope<'a, C, K: Key, const N: usize>(
    coll: &'a C,
    key: &K,
    storage_dir: Dir,
) -> Scope<'a, TreeScan<&'a C>, N>
where
    TreeScan<&'a C>: OrderedScan<Key = K>,
{
    let (start, end) = key_math::scope_bounds_n::<K, N>(key);
    Scope::from_parts(
        TreeScan { coll },
        key_math::prefix_key(key, N),
        start,
        end,
        storage_dir,
    )
}

/// Build a [`Scope`] over an iterable map collection.
pub(crate) fn map_scope<'a, M, K: Key, const N: usize>(
    map: &'a M,
    key: &K,
    storage_dir: Dir,
    iterable: bool,
) -> Option<Scope<'a, MapScan<&'a M>, N>>
where
    MapScan<&'a M>: OrderedScan<Key = K>,
{
    if !iterable {
        return None;
    }
    let (start, end) = key_math::scope_bounds_n::<K, N>(key);
    Some(Scope::from_parts(
        MapScan { view: map },
        key_math::prefix_key(key, N),
        start,
        end,
        storage_dir,
    ))
}