github.com/tidwall/btree
v1.8.1
#1481 most downloaded on Go modules
tidwall/btree
What this package is like to depend on
Last release 3 months ago
17 May 2026
Release timing varies
gaps range from 8 days to 13 months
Rarely documented
notes for 4 of 33 stable releases
Nothing withdrawn
no release was ever pulled
12 years old
97 releases · first in 2014
4 releases in the last 12 months
see the full history below
Release timeline
97 releases · Aug 2014 to May 2026Releases
latest 60 of 97-
v1.8.2-0.20260517004655-34be4b89c69017 May 2026 pre-releaseNothing published for this version
-
v1.8.2-0.20260228094419-a72b8ecd33e428 Feb 2026 pre-releaseNothing published for this version
-
v1.8.2-0.20251103153907-da3712be86f903 Nov 2025 pre-releaseNothing published for this version
-
v1.8.2-0.20250806233643-9ce5205f5d8c06 Aug 2025 pre-releaseNothing published for this version
-
v1.8.105 Aug 2025 -
v1.8.1-0.20250705014644-82b45e942cde05 Jul 2025 pre-releaseNothing published for this version
-
v1.8.004 Jul 2025Release notes
Open source →This commit adds the two new methods DeleteRange(min, max) and
DeleteAscend(min, iter) for efficiently deleting a sub-range and performing an
iteration-based delete on items.Prior to this commit the two options for deleting data were Delete(key) and
DeleteHint(key, hint).These worked fine in most cases where a one-off deletion is all that's needed.
But for batch or filter-like deletions, these are suboptimal because they
require knowing the keys beforehand. Meaning the user will likely need to call
something like the Ascend(min, iter) iterator to grab the keys and store them
into temporary list before looping over the list to perform the actual deletes.The new DeleteAscend(min, iter) function, like the traditional Ascend(min, iter)
function, accepts an iterator callback and ranges over the items starting at
min. The user controls the iterator by returning an Action type. The callback
is called for each item until it reaches the end of the tree or until the user
returns Stop. If the user returns Delete, the item is deleted. The value Keep
can be returns to keep the existing item and continue iterating.This implementation of DeleteAscend is optimized to avoid having to continually
traverse the tree for each item. Rather, it works to keep the cursor at the
leaf level as much as possible, moving up and down tree in a non-recursive loop.The new DeleteRange(min, max) function accepts a min (inclusive) and max
(exclusive) sub-range. All items in the range are deleted and returned to the
user. This operation is very fast because in many cases branch nodes can
be completely removed without visiting their internal children. This allows for
large spans of branch node removals to feel near instant. Since this B-tree
library adopts the properties of a Counted B-tree, the number of items in the
subtrees are know at the branch node level, allowing for easy maintenance
of parent node counts.There's also an optional param for DeleteRange that, when provided, allows for
ignoring returning the deleted items, further increasing performance.Benchmarks
Some basic benchmarks are included in the btreeg_test.go file.
Run 'go test -run TestContiguousDelete'
It uses the Delete, DeleteHint, DeleteAscend, and DeleteRange strategies.
Also included is a DeleteRange that does not return the deleted results.What each bench does is create a randomly sized B-tree, up to 200k items.
Then it performs a batch delete of a random window size up to 50% the number
of items in the tree. It then performs multiple runs until the total number of
deleted items is greater than 200k. Each run builds a new tree. Only the
delete operations are calculated in the duration.These are the results on a MacBook M1.
Delete deleted 204,536 items in 0.0242 secs, 118 ns/item, 8,458,572/s
DeleteHint deleted 204,605 items in 0.0184 secs, 90 ns/item, 11,145,431/s
DeleteAscend deleted 200,598 items in 0.0120 secs, 60 ns/item, 16,771,705/s
DeleteRange deleted 200,591 items in 0.0023 secs, 11 ns/item, 87,355,868/s
DeleteRangeNoRet deleted 200,861 items in 0.0013 secs, 7 ns/item, 150,040,823/s -
v1.7.1-0.20240609154626-51838063d45309 Jun 2024 pre-releaseNothing published for this version
-
v1.7.006 Sep 2023Release notes
Open source →These new functions allow for using a path hint with iterators,
making it potentially faster when seeking to the first item in the iteration.Benchmarks:
https://github.com/tidwall/btree-benchmark
About path hints:
https://github.com/tidwall/btree/blob/master/PATH_HINT.md
Usage:
tr.AscendHint(key, iter, &hint) // iterate items that are >= key, ascending tr.DescendHint(key, iter, &hint) // iterate items that are <= key, descending iter.SeekHint(key, &hint) // seek to item that is >= key
-
v1.6.1-0.20230906214737-8d3586de4bce06 Sep 2023 pre-releaseNothing published for this version
-
v1.6.1-0.20230330191724-6b260913388230 Mar 2023 pre-releaseNothing published for this version
-
v1.6.008 Dec 2022Release notes
Open source →This commits includes new Mut methods which ensure that values get
correctly copied, if needed, following a btree Copy() operations.This effictively allows for the BTree Copy method to create an isolated
snapshot that cascades to the interior values. Such as a BTree that has
nested BTrees as values.Mut methods are only useful when all of the following are true:
- The interior data of the values require changes.
- The value is a pointer type.
- The BTree has been copied using
Copy()orIsoCopy(). - The value itself has a
Copy()orIsoCopy()method.
Mut methods may modify the tree structure and should have the same
considerations as other mutable operations like Set, Delete, Clear, etc.New methods include GetMut, ScanMut, AscendMut, DescendMut, ReverseMut,
IterMut, MinMut, MaxMut, etc. -
v1.5.3-0.20230904230706-ccc2c19c0e2304 Sep 2023 pre-releaseNothing published for this version
-
v1.5.209 Nov 2022Nothing published for this version
-
v1.5.105 Nov 2022Nothing published for this version
-
v1.5.1-0.20221104150357-2744e70663e604 Nov 2022 pre-releaseNothing published for this version
-
v1.5.003 Nov 2022Nothing published for this version
-
v1.4.422 Sep 2022Nothing published for this version
-
v1.4.313 Sep 2022Nothing published for this version
-
v1.4.219 Aug 2022Nothing published for this version
-
v1.4.112 Aug 2022Nothing published for this version
-
v1.4.012 Aug 2022Nothing published for this version
-
v1.3.2-0.20220503231556-c519059cfa6303 May 2022 pre-releaseNothing published for this version
-
v1.3.2-0.20220424101759-c00790f349c424 Apr 2022 pre-releaseNothing published for this version
-
v1.3.120 Apr 2022Nothing published for this version
-
v1.3.013 Apr 2022Nothing published for this version
-
v1.2.208 Apr 2022Nothing published for this version
-
v1.2.127 Mar 2022Nothing published for this version
-
v1.2.1-0.20220315183609-34b1fa7b1ca215 Mar 2022 pre-releaseNothing published for this version
-
v1.2.015 Mar 2022Nothing published for this version
-
v1.1.1-0.20220312162251-e35874a0b03112 Mar 2022 pre-releaseNothing published for this version
-
v1.1.1-0.20220304141120-45aada57e88004 Mar 2022 pre-releaseNothing published for this version
-
v1.1.1-0.20220304011139-44d5878b011b04 Mar 2022 pre-releaseNothing published for this version
-
v1.1.1-0.20220220161908-7bec22d8e3fa20 Feb 2022 pre-releaseNothing published for this version
-
v1.1.1-0.20220220154919-6900c1fdf3a220 Feb 2022 pre-releaseNothing published for this version
-
v1.1.1-0.20220103194347-7411d393052203 Jan 2022 pre-releaseNothing published for this version
-
v1.1.1-0.20211225171117-501665b6dda425 Dec 2021 pre-releaseNothing published for this version
-
v1.1.1-0.20211225170343-b825cc77de2825 Dec 2021 pre-releaseNothing published for this version
-
v1.1.1-0.20211225170125-a6d3dc1a940925 Dec 2021 pre-releaseNothing published for this version
-
v1.1.1-0.20211225034604-275a6a9dbeab25 Dec 2021 pre-releaseNothing published for this version
-
v1.1.1-0.20211224172409-40e5f803476c24 Dec 2021 pre-releaseNothing published for this version
-
v1.1.018 Dec 2021Nothing published for this version
-
v1.0.115 Dec 2021Nothing published for this version
-
v1.0.1-0.20211215020521-1f729fa14b1b15 Dec 2021 pre-releaseNothing published for this version
-
v1.0.1-0.20211215015416-54726ba2a76915 Dec 2021 pre-releaseNothing published for this version
-
v1.0.1-0.20211212110029-77a63d5b795312 Dec 2021 pre-releaseNothing published for this version
-
v1.0.010 Dec 2021Nothing published for this version
-
v0.7.2-0.20211224171800-efe71b1652a124 Dec 2021 pre-releaseNothing published for this version
-
v0.7.2-0.20211224162836-5d678512b68a24 Dec 2021 pre-releaseNothing published for this version
-
v0.7.2-0.20211218005449-cbb03286d2f218 Dec 2021 pre-releaseNothing published for this version
-
v0.7.2-0.20211215020658-4d48ed30a06115 Dec 2021 pre-releaseNothing published for this version
-
v0.7.2-0.20211211132910-4215444137fc11 Dec 2021 pre-releaseNothing published for this version
-
v0.7.2-0.20211210232212-09f10b302a7810 Dec 2021 pre-releaseNothing published for this version
-
v0.7.2-0.20211210231906-5fcebaaa738410 Dec 2021 pre-releaseNothing published for this version
-
v0.7.2-0.20211204160815-0601e1ff3d2c04 Dec 2021 pre-releaseNothing published for this version
-
v0.7.2-0.20211204155754-b523c7a221e104 Dec 2021 pre-releaseNothing published for this version
-
v0.7.2-0.20211129231429-6e0be41e386429 Nov 2021 pre-releaseNothing published for this version
-
v0.7.2-0.20211126230026-6e50203fe13e26 Nov 2021 pre-releaseNothing published for this version
-
v0.7.126 Nov 2021Nothing published for this version
-
v0.7.026 Nov 2021Nothing published for this version