sled
sled copied to clipboard
An method should be added to determine whether the `Tree` exists
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.
cc @spacejam
Db::contains_tree (doesn't seem to be on crates.io yet)