blob: 0a240be59134b1a7524ac9b334acaafafd592c77 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
extern crate lmdb;
extern crate tempdir;
use self::tempdir::TempDir;
use lmdb::{
Environment,
Transaction,
WriteFlags,
};
pub fn get_key(n: u32) -> String {
format!("key{}", n)
}
pub fn get_data(n: u32) -> String {
format!("data{}", n)
}
pub fn setup_bench_db(num_rows: u32) -> (TempDir, Environment) {
let dir = TempDir::new("test").unwrap();
let env = Environment::new().open(dir.path()).unwrap();
{
let db = env.open_db(None).unwrap();
let mut txn = env.begin_rw_txn().unwrap();
for i in 0..num_rows {
txn.put(db, &get_key(i), &get_data(i), WriteFlags::empty()).unwrap();
}
txn.commit().unwrap();
}
(dir, env)
}
|