#![deny(missing_docs)]
#![warn(clippy::pedantic)]
#![warn(clippy::nursery)]
#![allow(clippy::inline_always)]
#![allow(clippy::multiple_crate_versions)]
#![allow(clippy::cast_ptr_alignment)]
#![allow(clippy::option_if_let_else)]
#[cfg(feature = "mimalloc")]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
#[cfg(feature = "tracing")]
pub fn init_tracing() {
use std::env as StdEnv;
use std::fs as StdFs;
use std::sync::OnceLock;
use tracing_subscriber::{EnvFilter, Layer, layer::SubscriberExt, util::SubscriberInitExt};
static GUARD: OnceLock<tracing_appender::non_blocking::WorkerGuard> = OnceLock::new();
GUARD.get_or_init(|| {
let log_dir: String =
StdEnv::var("MASSTREE_LOG_DIR").unwrap_or_else(|_| "logs".to_string());
let console_enabled: bool = false;
let filter_str: String =
StdEnv::var("RUST_LOG").unwrap_or_else(|_| "masstree=info".to_string());
let _ = StdFs::create_dir_all(&log_dir);
let file_appender = tracing_appender::rolling::never(&log_dir, "masstree.jsonl");
let (non_blocking, guard) = tracing_appender::non_blocking(file_appender);
let file_layer = tracing_subscriber::fmt::layer()
.with_writer(non_blocking)
.with_thread_ids(true)
.with_thread_names(true)
.with_target(true)
.with_file(true)
.with_line_number(true)
.json()
.with_filter(
EnvFilter::try_new(&filter_str).unwrap_or_else(|_| EnvFilter::new("info")),
);
let console_layer = if console_enabled {
Some(
tracing_subscriber::fmt::layer()
.with_thread_ids(true)
.compact()
.with_filter(
EnvFilter::try_new(&filter_str).unwrap_or_else(|_| EnvFilter::new("trace")),
),
)
} else {
None
};
let _ = tracing_subscriber::registry()
.with(file_layer)
.with(console_layer)
.try_init();
guard
});
}
#[cfg(not(feature = "tracing"))]
pub const fn init_tracing() {}
pub(crate) mod alloc15;
pub(crate) mod alloc_trait;
pub(crate) mod hints;
pub(crate) mod inline;
pub(crate) mod internode;
pub(crate) mod key;
pub(crate) mod ksearch;
pub(crate) mod leaf15;
pub(crate) mod leaf_trait;
pub(crate) mod link;
pub(crate) mod node_pool;
pub(crate) mod nodeversion;
pub(crate) mod ordering;
pub(crate) mod permuter;
pub(crate) mod policy;
pub(crate) mod prefetch;
mod retirement;
mod shard_counter;
pub(crate) mod suffix;
pub(crate) mod tree;
pub use tree::{BatchEntry, BatchInsertResult, Entry, OccupiedEntry, VacantEntry, batch};
pub use tree::{InsertError, RemoveError};
pub use tree::{KeysIter, RangeBound, RangeIter, ScanEntry, ValuesIter};
pub use tree::{MassTree, MassTree15, MassTree15Inline, MassTreeGeneric};
pub use inline::bits::InlineBits;
pub use policy::RefPolicy as RefLeafPolicy;
pub use policy::{BoxPolicy, LeafPolicy, ValuePtr, ValueRef};
pub use key::{IKEY_SIZE, Key, MAX_KEY_LENGTH};
pub use alloc_trait::TreeAllocator;
pub use alloc15::SeizeAllocator;
pub use internode::InternodeNode;
pub use leaf_trait::{TreeInternode, TreeLeafNode, TreePermutation};
pub use leaf15::LeafNode15;
pub use nodeversion::NodeVersion;
pub use permuter::{AtomicPermuter, AtomicPermuter15, MAX_WIDTH, Permuter, Permuter15};
pub use suffix::{PermutationProvider, SuffixBag};
pub use retirement::BatchedRetire;
pub(crate) use link::Linker;