Struct lsmlite_rs::DbConf

source ·
pub struct DbConf { /* private fields */ }
Expand description

This struct contains the configuration of a database.

Implementations§

source§

impl DbConf

source

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.

source

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:

  1. The path the database file will be put in.
  2. The name of the database file.
  3. The mode it will work on (single- or multi-threaded).
  4. Whether the database is to be used in read-only mode, or writes are also allowed.
  5. The upper-layer set of (Prometheus) metrics to be updated by the database.
  6. 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§

source§

impl Clone for DbConf

source§

fn clone(&self) -> DbConf

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for DbConf

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for DbConf

source§

fn default() -> DbConf

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more