Struct lsmlite_rs::DbConf
source · pub struct DbConf { /* private fields */ }
Expand description
This struct contains the configuration of a database.
Implementations§
source§impl DbConf
impl DbConf
sourcepub fn new(db_path: impl Into<PathBuf>, db_name: String) -> Self
pub fn new(db_path: impl Into<PathBuf>, db_name: String) -> Self
The minimum amount of information a database requires is
the path the file will be put in as well as the name of it.
This version of new
will create a database using
no background threads, without Prometheus metrics, and using
no compression.
sourcepub fn new_with_parameters(
db_path: impl Into<PathBuf>,
db_name: String,
mode: LsmMode,
handle_mode: LsmHandleMode,
metrics: Option<LsmMetrics>,
compression: LsmCompressionLib
) -> Self
pub fn new_with_parameters( db_path: impl Into<PathBuf>, db_name: String, mode: LsmMode, handle_mode: LsmHandleMode, metrics: Option<LsmMetrics>, compression: LsmCompressionLib ) -> Self
A full database configuration requires:
- The path the database file will be put in.
- The name of the database file.
- The mode it will work on (single- or multi-threaded).
- Whether the database is to be used in read-only mode, or writes are also allowed.
- The upper-layer set of (Prometheus) metrics to be updated by the database.
- Whether compression is to be used or not, and what kind.
Example
use prometheus::{Histogram, HistogramOpts};
use lsmlite_rs::*;
let default_checkpointer_kbs_buckets: Vec::<f64> =
vec![2048., 4096., 5120., 6144., 7168., 8192., 12288., 16384., 20480.];
let default_worker_kbs_buckets: Vec::<f64> =
vec![1024., 2048., 4096., 8192., 16384., 24576., 32768., 49152., 65536.];
let default_write_times_sec_buckets: Vec::<f64> =
vec![0.001, 0.0025, 0.005, 0.0075, 0.01, 0.025, 0.05, 0.075, 0.1, 0.5, 1.0, 5.0, 10.];
let opts_1 = HistogramOpts::new(
"non_typed_write_times_s",
"non_typed_write_times_s help"
)
.buckets(default_write_times_sec_buckets.clone());
let opts_2 = HistogramOpts::new(
"work_kbs",
"work_kbs help"
)
.buckets(default_worker_kbs_buckets.clone());
let opts_3 = HistogramOpts::new(
"work_times_s",
"work_times_s help"
)
.buckets(default_write_times_sec_buckets.clone());
let opts_4 = HistogramOpts::new(
"checkpoint_kbs",
"checkpoint_kbs help"
)
.buckets(default_checkpointer_kbs_buckets.clone());
let opts_5 = HistogramOpts::new(
"checkpoint_times_s",
"checkpoint_times_s help"
)
.buckets(default_write_times_sec_buckets);
let metrics = LsmMetrics {
write_times_s: Histogram::with_opts(opts_1).unwrap(),
work_kbs: Histogram::with_opts(opts_2).unwrap(),
work_times_s: Histogram::with_opts(opts_3).unwrap(),
checkpoint_kbs: Histogram::with_opts(opts_4).unwrap(),
checkpoint_times_s: Histogram::with_opts(opts_5).unwrap(),
};
let db_conf = DbConf::new_with_parameters(
"/tmp/",
"my_db_z".to_string(),
LsmMode::LsmNoBackgroundThreads,
LsmHandleMode::ReadWrite,
Some(metrics),
LsmCompressionLib::ZLib,
);
let mut db: LsmDb = Default::default();
let rc = db.initialize(db_conf)?;
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for DbConf
impl Send for DbConf
impl Sync for DbConf
impl Unpin for DbConf
impl UnwindSafe for DbConf
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more