Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Update LMDB version to latest from master #23

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ members = [
[dependencies]
bitflags = "1"
libc = "0.2"
lmdb-sys = "0.8.0"
lmdb-sys = { path = "lmdb-sys" }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly, crates.io doesn't support publishing a crate with a path dependency like this, and that doesn't seem likely to change, per rust-lang/cargo#1565. So we'll have to publish the new version to crates.io (renaming it in the process to avoid the naming conflict with this version, which is controlled and updated more slowly by the upstream repo danburkert/lmdb-rs).

However, while I haven't tested it, a path dependency like this probably does work if you're depending on this crate via a Git repo reference rather than a crates.io reference. So this is probably fine for a branch where we track LMDB's upstream master branch but don't publish the crate on crates.io, and you depend on the Git repo directly.


[dev-dependencies]
rand = "0.4"
Expand Down
32 changes: 32 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,36 @@ mod test_utils {
tx.commit().expect("tx.commit")
}
}

// verify that the map file is sparsly allocated
// this used to fail on earlier versions of LMDB on Windows, before ITS#8324
#[test]
fn verify_sparse() {
const HEIGHT_KEY: [u8; 1] = [0];

let dir = TempDir::new("test").unwrap();

{
let env = {
let mut builder = Environment::new();
builder.set_map_size(1_000_000_000);
builder.open(dir.path()).expect("open lmdb env")
};
let db = env.open_db(None).unwrap();

for height in 0..1000 {
let mut value = [0u8; 8];
LittleEndian::write_u64(&mut value, height);
let mut tx = env.begin_rw_txn().expect("begin_rw_txn");
tx.put(db, &HEIGHT_KEY, &value, WriteFlags::empty())
.expect("tx.put");
tx.commit().expect("tx.commit")
}
}

let size = std::fs::metadata(dir.path().join("data.mdb"))
.expect("get file size")
.len();
assert!(size < 1_000_000);
}
}