Skip to content

Commit

Permalink
Merge pull request #614 from ahrtr/cursor_20231117
Browse files Browse the repository at this point in the history
Update doc to clarify the behavior when removing key/value pairs during iteration
  • Loading branch information
ahrtr authored Dec 8, 2023
2 parents 95a982c + 173f1cf commit 568e754
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,11 @@ When you have iterated to the end of the cursor then `Next()` will return a
before calling `Next()` or `Prev()`. If you do not seek to a position then
these functions will return a `nil` key.

If you remove key/value pairs during iteration, the cursor may automatically
move to the next position if present in current node each time removing a key.
When you call `c.Next()` after removing a key, it may skip one key/value pair.
Refer to [pull/611](https://github.com/etcd-io/bbolt/pull/611) to get more detailed info.

During iteration, if the key is non-`nil` but the value is `nil`, that means
the key refers to a bucket rather than a value. Use `Bucket.Bucket()` to
access the sub-bucket.
Expand Down Expand Up @@ -869,6 +874,12 @@ Here are a few things to note when evaluating and using Bolt:
to grow. However, it's important to note that deleting large chunks of data
will not allow you to reclaim that space on disk.

* Removing key/values pairs in a bucket during iteration on the bucket using
cursor may not work properly. Each time when removing a key/value pair, the
cursor may automatically move to the next position if present. When users
call `c.Next()` after removing a key, it may skip one key/value pair.
Refer to https://github.com/etcd-io/bbolt/pull/611 for more detailed info.

For more information on page allocation, [see this comment][page-allocation].

[page-allocation]: https://github.com/boltdb/bolt/issues/308#issuecomment-74811638
Expand Down

0 comments on commit 568e754

Please sign in to comment.