Macro reopen

Source
macro_rules! reopen {
    ( $db:expr, $($cf:expr;<$K:ty, $V:ty>),*) => { ... };
}
Expand description

A helper macro to reopen multiple column families. The macro returns a tuple of DBMap structs in the same order that the column families are defined.

§Arguments

  • db - a reference to a rocks DB object
  • cf;<ty,ty> - a comma separated list of column families to open. For each column family a concatenation of column family name (cf) and Key-Value <ty, ty> should be provided.

§Examples

We successfully open two different column families.

use typed_store::reopen;
use typed_store::rocks::*;
use tempfile::tempdir;
use prometheus::Registry;
use std::sync::Arc;
use typed_store::metrics::DBMetrics;
use core::fmt::Error;

#[tokio::main]
async fn main() -> Result<(), Error> {
const FIRST_CF: &str = "First_CF";
const SECOND_CF: &str = "Second_CF";


/// Create the rocks database reference for the desired column families
let rocks = open_cf(tempdir().unwrap(), None, MetricConf::default(), &[FIRST_CF, SECOND_CF]).unwrap();

/// Now simply open all the column families for their expected Key-Value types
let (db_map_1, db_map_2) = reopen!(&rocks, FIRST_CF;<i32, String>, SECOND_CF;<i32, String>);
Ok(())
}