Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change transaction apply_batch to take argument by-reference. #1015

Merged
merged 1 commit into from
Mar 13, 2020

Conversation

Erk-
Copy link
Contributor

@Erk- Erk- commented Mar 12, 2020

This change facilitates that you can setup a batch and then execute it
inside of a transaction. For example:

let db = config.open().unwrap();
let t1 = db.open_tree(b"1")?;

let mut b1 = Batch::default();
b1.insert(b"k1", b"v1");
b1.insert(b"k2", b"v2");

t1.transaction(|tree| {
    tree.apply_batch(&b1)?;
    Ok(())
})?;

This PR is the implementation of #1013 if it is accepted.


I did have a spurious fail in the test log_writebatch, but I am unsure if
it is connected to this change in any way.

This change facilitates that you can setup a batch and then execute it
inside of a transaction. For example:

```rust
let db = config.open().unwrap();
let t1 = db.open_tree(b"1")?;

let mut b1 = Batch::default();
b1.insert(b"k1", b"v1");
b1.insert(b"k2", b"v2");

t1.transaction(|tree| {
    tree.apply_batch(&b1)?;
    Ok(())
})?;
```

Signed-off-by: Valdemar Erk <[email protected]>
@spacejam
Copy link
Owner

@Erk- this looks good, thanks for improving this :) I'll add an entry to the CHANGELOG mentioning this breaking change for the upcoming 0.32 release.

@spacejam spacejam merged commit 472d29b into spacejam:master Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants