bitkv_rs/
option.rs

1use std::path::PathBuf;
2
3#[derive(Debug, Clone)]
4pub struct Options {
5  // database directory
6  pub dir_path: PathBuf,
7
8  //data file size
9  pub data_file_size: u64,
10
11  // sync writes or not
12  pub sync_writes: bool,
13
14  // the number of bytes to write before sync
15  pub bytes_per_sync: usize,
16
17  // index type option
18  pub index_type: IndexType,
19
20  // use mmap or not
21  pub mmap_at_startup: bool,
22
23  // merge threshold
24  pub file_merge_threshold: f32,
25}
26
27#[derive(Debug, Clone, PartialEq, Eq)]
28pub enum IndexType {
29  /// Btree index
30  BTree,
31
32  /// SkipList index
33  SkipList,
34
35  /// B+Tree index
36  BPlusTree,
37}
38
39impl Default for Options {
40  fn default() -> Self {
41    Self {
42      dir_path: std::env::temp_dir().join("bitkv-rs"),
43      data_file_size: 256 * 1024 * 1024, // 256MB
44      sync_writes: false,
45      bytes_per_sync: 0,
46      index_type: IndexType::BTree,
47      mmap_at_startup: true,
48      file_merge_threshold: 0.6,
49    }
50  }
51}
52pub struct IteratorOptions {
53  pub prefix: Vec<u8>,
54  pub reverse: bool,
55}
56
57#[allow(clippy::derivable_impls)]
58impl Default for IteratorOptions {
59  fn default() -> Self {
60    Self {
61      prefix: Default::default(),
62      reverse: false,
63    }
64  }
65}
66
67pub struct WriteBatchOptions {
68  // max batch number in one batch write
69  pub max_batch_num: usize,
70
71  // when commit if sync or not
72  pub sync_writes: bool,
73}
74
75impl Default for WriteBatchOptions {
76  fn default() -> Self {
77    Self {
78      max_batch_num: 1000,
79      sync_writes: true,
80    }
81  }
82}
83
84#[derive(Debug, Clone, Copy, PartialEq, Eq)]
85pub enum IOManagerType {
86  // Standard IO file
87  StandardFileIO,
88
89  // Memory Map IO
90  MemoryMap,
91}