redb icon indicating copy to clipboard operation
redb copied to clipboard

Implement additional APIs from BtreeMap

Open cberner opened this issue 3 years ago • 2 comments

There are several methods on std::collections::BtreeMap that would also make sense to have on Table. Such as:

  • [ ] drain()
  • [ ] pop_first()
  • [ ] pop_last()

cberner avatar Feb 07 '22 05:02 cberner

This can't be implemented in a nice way. drain() is suppose to remove the entries even if the iterator is dropped. However, removing from a redb Database must allocate pages which could result in an out of space error, and drop() can't return a Result obviously.

cberner avatar Feb 11 '22 01:02 cberner

Actually this can be. All the removals just need to be done during the drain iterator creation, and only the page freeing during Drop

cberner avatar Feb 13 '22 01:02 cberner