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

Partition::clear #132

Open
marvin-j97 opened this issue Jan 31, 2025 · 6 comments
Open

Partition::clear #132

marvin-j97 opened this issue Jan 31, 2025 · 6 comments
Assignees
Labels
api easy enhancement New feature or request

Comments

@marvin-j97
Copy link
Collaborator

Just run a "Nuke compaction" (followed by dropping all blob files if blob tree) - clear() is not transactional!!!

@marvin-j97 marvin-j97 added easy enhancement New feature or request labels Jan 31, 2025
@marvin-j97 marvin-j97 self-assigned this Jan 31, 2025
@marvin-j97 marvin-j97 added the api label Jan 31, 2025
@anidotnet
Copy link

anidotnet commented Feb 20, 2025

Does this clear() method intends to delete all items from partition? Because, I am looking for such operation and I could not find one for a Partition.

@marvin-j97
Copy link
Collaborator Author

Yes. Generally I find clearing a table to be an anti-pattern, because it's faster to just create a new partition. But with clear() it's possible to clear it in O(1) and reuse the partition name, so it's just more convenient, but not transactional.

@anidotnet
Copy link

Thanks for your quick response. Could you please give an estimate by when this api would be available in release?

@marvin-j97
Copy link
Collaborator Author

marvin-j97 commented Feb 20, 2025

Not right now, it should be pretty simple, there just needs to be some coordination added to make sure there are no outstanding compactions going on when clearing (there needs to be a write lock & the clear() needs to make sure it gets all the disk segments) - which would also allow fjall-rs/lsm-tree#105.

@anidotnet
Copy link

anidotnet commented Feb 20, 2025

So in it's current form how to clear a partition efficiently instead of iterating and removing each item?

Provided, in my use case I am holding a Partition in a struct and calling clear from inside the struct's method. The struct is a map like data structure and I am not planning to have any mut &self method for the struct.

Holding a keyspace object instead of a partition in the struct and opening partition for each map operations is not feasible due to the write lock in open_partition method which will significantly harm bulk operations.

@marvin-j97
Copy link
Collaborator Author

So in it's current form how to clear a partition efficiently instead of iterating and removing each item?

Currently none, there are two ways really, either 1) a range tombstone, which can be transactional, or 2) this issue, which can not be transactional because it will simply nuke all the data.

Holding a keyspace object instead of a partition in the struct and opening partition for each map operations is not feasible due to the write lock in open_partition method which will significantly harm bulk operations.

It's an RwLock, so for the most time, the lock should not actually lock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api easy enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants