Skip to content

Commit

Permalink
Make the cookbook env opening unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerollmops committed Mar 4, 2024
1 parent da5a0ea commit ff67616
Showing 1 changed file with 32 additions and 20 deletions.
52 changes: 32 additions & 20 deletions heed/src/cookbook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
//!
//! fs::create_dir_all(&env_path)?;
//!
//! let env = EnvOpenOptions::new()
//! .map_size(10 * 1024 * 1024) // 10MB
//! .max_dbs(3) // Number of opened databases
//! .open(env_path)?;
//! let env = unsafe {
//! EnvOpenOptions::new()
//! .map_size(10 * 1024 * 1024) // 10MB
//! .max_dbs(3) // Number of opened databases
//! .open(env_path)?
//! };
//!
//! let rtxn = env.read_txn()?;
//! let unnamed: Database<Str, DecodeIgnore> =
Expand Down Expand Up @@ -165,10 +167,12 @@
//!
//! fs::create_dir_all(&path)?;
//!
//! let env = EnvOpenOptions::new()
//! .map_size(10 * 1024 * 1024) // 10MB
//! .max_dbs(3000)
//! .open(path)?;
//! let env = unsafe {
//! EnvOpenOptions::new()
//! .map_size(10 * 1024 * 1024) // 10MB
//! .max_dbs(3000)
//! .open(path)?
//! };
//!
//! let mut wtxn = env.write_txn()?;
//! let db: Database<LogKeyCodec, Str> = env.create_database(&mut wtxn, None)?;
Expand Down Expand Up @@ -228,9 +232,11 @@
//!
//! fs::create_dir_all(&path)?;
//!
//! let env = EnvOpenOptions::new()
//! .map_size(16384) // one page
//! .open(&path)?;
//! let env = unsafe {
//! EnvOpenOptions::new()
//! .map_size(16384) // one page
//! .open(&path)?
//! };
//!
//! let mut wtxn = env.write_txn()?;
//! let db: Database<Str, Str> = env.create_database(&mut wtxn, None)?;
Expand All @@ -247,9 +253,11 @@
//! // when no transaction are running so closing the env is easier.
//! env.prepare_for_closing().wait();
//!
//! let env = EnvOpenOptions::new()
//! .map_size(10 * 16384) // 10 pages
//! .open(&path)?;
//! let env = unsafe {
//! EnvOpenOptions::new()
//! .map_size(10 * 16384) // 10 pages
//! .open(&path)?
//! };
//!
//! let mut wtxn = env.write_txn()?;
//! let db: Database<Str, Str> = env.create_database(&mut wtxn, None)?;
Expand Down Expand Up @@ -291,9 +299,11 @@
//!
//! fs::create_dir_all(&path)?;
//!
//! let env = EnvOpenOptions::new()
//! .map_size(1024 * 1024 * 100) // 100 MiB
//! .open(&path)?;
//! let env = unsafe {
//! EnvOpenOptions::new()
//! .map_size(1024 * 1024 * 100) // 100 MiB
//! .open(&path)?
//! };
//!
//! let mut wtxn = env.write_txn()?;
//! let db: Database<Str, SerdeJson<StringMap>> = env.create_database(&mut wtxn, None)?;
Expand Down Expand Up @@ -369,9 +379,11 @@
//!
//! fs::create_dir_all(&path)?;
//!
//! let env = EnvOpenOptions::new()
//! .map_size(1024 * 1024 * 100) // 100 MiB
//! .open(&path)?;
//! let env = unsafe {
//! EnvOpenOptions::new()
//! .map_size(1024 * 1024 * 100) // 100 MiB
//! .open(&path)?
//! };
//!
//! let mut wtxn = env.write_txn()?;
//! let db: Database<Str, Str> = env.create_database(&mut wtxn, None)?;
Expand Down

0 comments on commit ff67616

Please sign in to comment.