1use lazy_static::lazy_static;
2use std::path::PathBuf;
3
4lazy_static! {
5 pub static ref DEFAULT_DIR_PATH: PathBuf = std::env::temp_dir().join("flash-kv");
6}
7
8#[derive(Debug, Clone)]
9pub struct Options {
10 pub dir_path: PathBuf,
12
13 pub data_file_size: u64,
15
16 pub sync_writes: bool,
18
19 pub bytes_per_sync: usize,
21
22 pub index_type: IndexType,
24
25 pub mmap_at_startup: bool,
27
28 pub file_merge_threshold: f32,
30}
31
32#[derive(Debug, Clone, PartialEq, Eq)]
33pub enum IndexType {
34 BTree,
36
37 SkipList,
39
40 BPlusTree,
42}
43
44impl Default for Options {
45 fn default() -> Self {
46 Self {
47 dir_path: DEFAULT_DIR_PATH.clone(),
48 data_file_size: 256 * 1024 * 1024, sync_writes: false,
50 bytes_per_sync: 0,
51 index_type: IndexType::BTree,
52 mmap_at_startup: true,
53 file_merge_threshold: 0.6,
54 }
55 }
56}
57pub struct IteratorOptions {
58 pub prefix: Vec<u8>,
59 pub reverse: bool,
60}
61
62#[allow(clippy::derivable_impls)]
63impl Default for IteratorOptions {
64 fn default() -> Self {
65 Self {
66 prefix: Default::default(),
67 reverse: false,
68 }
69 }
70}
71
72pub struct WriteBatchOptions {
73 pub max_batch_num: usize,
75
76 pub sync_writes: bool,
78}
79
80impl Default for WriteBatchOptions {
81 fn default() -> Self {
82 Self {
83 max_batch_num: 1000,
84 sync_writes: true,
85 }
86 }
87}
88
89#[derive(Debug, Clone, Copy, PartialEq, Eq)]
90pub enum IOManagerType {
91 StandardFileIO,
93
94 MemoryMap,
96}