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

An method should be added to determine whether the Tree exists #1429

Open
pidb opened this issue Oct 9, 2022 · 2 comments
Open

An method should be added to determine whether the Tree exists #1429

pidb opened this issue Oct 9, 2022 · 2 comments
Labels

Comments

@pidb
Copy link

pidb commented Oct 9, 2022

Use Case:

In my scenario, the data of different tenants is stored in different Trees, so that Tree as a tenant. When I create a Tree for a new tenant, I want to know if it has been created before. so I use something like the following to implementation a similar function

let volume_id_bytes = EncodeVolumeId(volume_id)?;
if let Some(_) = self
    .db
    .tree_names()
    .iter()
    .find(|name| **name == IVec::from(volume_id_bytes.as_slice()))
{
    return Err(Error::VolumeAlreadyExists(volume_id))
}

But I probably have hundreds of millions of volume ids, so I think there might be a problem with that.

I think we should add a method like this, e.g.

if db.existis_tree("tree") {
    return Err(...)
}
// do something...

Proposed Change:

I see that currently sled only has method for open_tree to use, I want to add an method like exists_tree.

@pidb pidb added the feature label Oct 9, 2022
@pidb
Copy link
Author

pidb commented Oct 11, 2022

cc @spacejam

@wackbyte
Copy link

wackbyte commented Nov 3, 2022

Db::contains_tree (doesn't seem to be on crates.io yet)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants