Skip to main content

tuwunel_database/map/
options.rs

1use std::sync::Arc;
2
3use rocksdb::{ReadOptions, ReadTier, WriteOptions};
4
5use crate::Engine;
6
7/// Builds iterator options restricted to block-cache reads.
8///
9/// The probe neither fills cache nor falls through to storage.
10#[inline]
11pub(crate) fn cache_iter_options_default(engine: &Arc<Engine>) -> ReadOptions {
12	let mut options = iter_options_default(engine);
13	options.set_read_tier(ReadTier::BlockCache);
14	options.fill_cache(false);
15	options
16}
17
18/// Builds the default options for a map iterator.
19///
20/// Iterator cleanup may purge obsolete files in the background.
21#[inline]
22pub(crate) fn iter_options_default(engine: &Arc<Engine>) -> ReadOptions {
23	let mut options = read_options_default(engine);
24	options.set_background_purge_on_iterator_cleanup(true);
25	options
26}
27
28/// Builds point-read options restricted to block cache.
29///
30/// The read neither fills cache nor falls through to storage.
31#[inline]
32pub(crate) fn cache_read_options_default(engine: &Arc<Engine>) -> ReadOptions {
33	let mut options = read_options_default(engine);
34	options.set_read_tier(ReadTier::BlockCache);
35	options.fill_cache(false);
36	options
37}
38
39/// Builds the base options shared by map reads and iterators.
40///
41/// Total-order seek is enabled. Checksum verification follows the engine
42/// setting.
43#[inline]
44pub(crate) fn read_options_default(engine: &Arc<Engine>) -> ReadOptions {
45	let mut options = ReadOptions::default();
46	options.set_total_order_seek(true);
47
48	if !engine.checksums {
49		options.set_verify_checksums(false);
50	}
51
52	options
53}
54
55/// Builds the default options for a map write.
56///
57/// The current engine configuration requires no map-specific overrides.
58#[inline]
59pub(crate) fn write_options_default(_engine: &Arc<Engine>) -> WriteOptions {
60	WriteOptions::default()
61}