63 Commits

Author SHA1 Message Date
Josh Rickmar
7a957f94b2 Introduce errors package and restore API compatibility
This moves the error variables that had been moved to the
internal/common package during recent refactoring to a non-internal
errors package, once again allowing consumers to test for particular
error conditions.

To preserve API compatibility with bbolt v1.3, these error variables
are also redefined in the bbolt package, with deprecation notice to
migrate to bbolt/errors.

Signed-off-by: Josh Rickmar <jrick@zettaport.com>
2023-04-06 13:26:30 +00:00
Benjamin Wang
a3a9877de6 encapsulate the logic of checking the page type
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-03-08 10:47:59 +08:00
Benjamin Wang
852b1df32f refactor: move inode to internal/common package
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-03-04 04:22:09 +08:00
Benjamin Wang
ea511567eb refactor both bolt and guts_cli based on the common package
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-03-04 04:22:09 +08:00
Piotr Tabor
80edaf14f0 Rename: pgid pgid => pgId pgid to avoid confusion.
Signed-off-by: Piotr Tabor <ptab@google.com>
2023-01-13 19:14:45 +01:00
Piotr Tabor
4b8c53388b
Merge pull request #250 from x1ddos/sort-order-docs
bucket,cursor: clarify sort order and seek algorithm
2022-12-21 22:07:36 +01:00
Piotr Tabor
ebca452da7 Add internal iterator to Bucket that goes over buckets.
So far the code was frequently traversing all the keys (ignoring flag whether key is a bucket)
and trying to open each of the keys as bucket (seeking the same entry from the scratch).

In this proposal, we iterate only through bucket keys.

Signed-off-by: Piotr Tabor <ptab@google.com>
2022-12-21 12:16:50 +01:00
Benjamin Wang
ed0438722e only perform assert on exported method
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-12-21 16:39:30 +08:00
dchaofei
f1918806b2 fix(cursor): Last needs skip empty pages
Signed-off-by: dchaofei <dchaofei@163.com>
2022-11-18 14:25:48 +08:00
alex
12fd02b542 bucket,cursor: clarify sort order and seek algorithm
The sort order isn't mentioned anywhere except one sentence in the
readme. So is seek. Although it can be inferred from B+tree and other
hints, it is important to be able to confirm from just reading doc
comments. So, make it explicit.
2020-10-22 19:26:12 +02:00
Christian Muehlhaeuser
0bf4edcf32 Avoid unnecessary conversions
No need to convert here, they are already of the right type.
2019-08-06 17:35:28 +00:00
Gyuho Lee
76a4670663 *: update import paths "go.etcd.io/bbolt"
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
2018-08-28 08:15:54 -07:00
blueblue
ebb8629339 cursor: remove redundant check when seek 2018-03-17 15:03:43 -07:00
Luke Champine
852d3024fa skip empty pages during cursor seek
This commit fixes an issue where keys are skipped by cursors after
deletions occur in a bucket. This occurred because the cursor seeks
to the leaf page but does not check if it is empty.

Fixes #429, #450
2015-11-05 22:39:15 -07:00
Ben Johnson
112f143631 Document key/value safety.
This commit adds safety documentation to the data accessor functions
in Bolt as well as the README. This was documented once in the package
level godoc but it's important enough that it should be more clear.
2015-03-24 11:06:28 -06:00
Ben Johnson
b4d00c394a Expand assertion statements.
This commit expands calls to _assert() that use variadic arguments. These calls require conversion to interface{} so there
was a large number of calls to Go's internal convT2E() function. In some profiling this was taking over 20% of total runtime.
I don't remember seeing this before Go 1.4 so perhaps something has changed.
2015-01-30 14:15:49 -05:00
Ben Johnson
74489c7516 Clarify cursor behavior after mutation. 2014-11-27 17:18:05 -07:00
Martin Kobetic
a00a88baef add Cursor.Delete() 2014-06-11 21:46:19 +00:00
Ben Johnson
511ecba69b Refactor Cursor.Next() to use Cursor.next(). 2014-06-09 12:37:07 -06:00
Ben Johnson
6ddb056698 Fix last element seek.
This commit fixes a bug with seeks where seeking to a key between the end
of a page and the beginning of the next page causes it to return nil. This
was fixed by calling Cursor.next() when the cursor ends up between pages.

This also changes Cursor.Next() so that calling Next() at the end of a bucket
leaves the cursor at the end instead of zeroing out the stack.

Fixes #186.

/cc @PreetamJinka
2014-06-09 11:07:25 -06:00
Ben Johnson
782ead0dbf Fix freelist allocation direction.
This commit fixes the freelist so that it frees from the beginning of the data file
instead of the end. It also adds a fast path for pages which can be allocated from
the first free pages and it includes read transaction stats.
2014-05-19 12:08:33 -06:00
Ben Johnson
0966dde0d4 Fix bucket free. 2014-05-07 10:37:50 -06:00
Tommi Virtanen
eaa47b6468 Document cursors seeing nested buckets 2014-05-04 18:32:59 -07:00
Tommi Virtanen
458400eb82 Cursor.Seek validity is indicated by key being nil 2014-05-04 18:30:30 -07:00
Ben Johnson
25fea2fd9f Refactor split/spill. 2014-05-03 16:21:28 -06:00
Ben Johnson
63a8cddd2b Add Cursor.Bucket() function.
This commit adds an accessor to the Cursor type to retrieve the Bucket that
it was created from.
2014-04-16 09:38:53 -04:00
Ben Johnson
698b07b074 Add nested buckets.
This commit adds the ability to create buckets inside of other buckets.
It also replaces the buckets page with a root bucket.

Fixes #56.
2014-04-11 12:36:54 -06:00
Ben Johnson
12204df0b5 Rename internal local Tx variables.
This commit changes the local Tx variables from "t" to "tx". This is partly
for consistency with external documentation but also because it just
annoys me for some reason.
2014-04-04 12:03:04 -06:00
Ben Johnson
482f00fdfc Add ErrTxClosed error.
Commit/Rollback and mutable calls on Tx and Bucket now return ErrTxClosed
if the transaction has already been committed or rolled back. Non-mutable
calls have added an assertion to check if the transaction is closed which
will cause a panic. I don't want to introduce an error return for accessor
methods that are being used improperly so I think the panic is appropriate.
2014-03-23 12:20:16 -06:00
Ben Johnson
4132080333 Fix Cursor.Last() on empty buckets.
@tv42 reported that creating a cursor on an empty bucket and then calling
Cursor.Last() causes an index out of range error and panics. This commit
adds a check for the page's item count being greater than zero.

Fixes #63.
2014-03-13 14:39:28 -06:00
Ben Johnson
c551e45a47 Consolidate Tx and RWTx. 2014-03-08 20:40:48 -07:00
Ben Johnson
57376f0905 Rename Transaction to Tx.
I changed the Transaction/RWTransaction types to Tx/RWTx, respectively. This makes the naming
more consistent with other packages such as database/sql. The txnid is changed to txid as well.
2014-03-08 17:04:02 -07:00
Ben Johnson
a1f43f4d60 Allow reads of unflushed nodes.
This commit allows cursors to read updated values from within the
RWTransaction.
2014-03-01 09:13:59 -07:00
Ben Johnson
956453b69f Minor refactor. 2014-02-28 15:13:07 -07:00
Ben Johnson
3b2fd8f2d3 Revert "Refactor Transaction/Bucket API."
This reverts commit 1ad2b99f281d587b767b36f886401e81d17915a9.
2014-02-22 22:54:54 -07:00
Ben Johnson
1ad2b99f28 Refactor Transaction/Bucket API. 2014-02-21 22:57:50 -07:00
Ben Johnson
15e0eae829 Bidirectional cursors. 2014-02-20 13:53:40 -07:00
Tommi Virtanen
8438c6ebc3 Cursor.Get is now Cursor.Seek, and returns the first possible key.
This makes range and prefix queries possible.

Closes: #44
2014-02-20 11:33:28 -08:00
Ben Johnson
2d1f21a40d Fix Cursor godoc for First(), Next(), and Get(). 2014-02-20 11:04:46 -07:00
Ben Johnson
d1952237ed Improve test coverage. 2014-02-15 23:45:17 -07:00
Ben Johnson
8ad59edd02 API Documentation. 2014-02-13 10:58:27 -07:00
Ben Johnson
b8122bf568 Cursor iteration. 2014-02-11 09:07:07 -07:00
Ben Johnson
509e93dff4 Add freelist. 2014-02-10 14:04:01 -07:00
Ben Johnson
3da04c52b9 Rebalance after deletion. 2014-02-08 23:13:54 -07:00
Ben Johnson
84939c21f6 Refactor node lookup. 2014-02-07 15:03:29 -07:00
Ben Johnson
8b3b81ef47 Fix quick tests. 2014-02-05 07:56:13 -07:00
Ben Johnson
1a17a2cf1e Add RWTransaction.Put(). 2014-02-01 12:30:37 -05:00
Ben Johnson
8d5757e9dd gofmt 2014-01-30 17:04:56 -05:00
Ben Johnson
149d48fb9e Fix leaf/branch deserialization. 2014-01-30 00:11:46 -05:00
Ben Johnson
4fc84daf2a Refactor meta.copy() and page.init(). 2014-01-29 22:35:58 -05:00