Commit Graph

40 Commits (d1a77a9c821e391c8058f22f970c2d4f44cbce50)

Author SHA1 Message Date
Ben Johnson 4f428feecc Merge pull request #208 from benbjohnson/open-timeout
Add Open() options, flock timeout.
2014-06-22 10:10:55 -06:00
Ben Johnson 0f585358f4 Change Bucket.NextSequence() to return uint64.
This commit changes NextSequence() to return a uint64 instead of an int. This also
removes the ErrSequenceOverflow error condition since overflowing a uint64 is unlikely.

Fixes #39.
2014-06-22 09:33:28 -06:00
Ben Johnson 00ee0da528 Add Open() options, flock timeout.
This commit changes Open() to provide an additional Options argument. The options
argument currently only has a Timeout which will cause the Open() to return
ErrTimeout if a file lock cannot be obtained in time.

Fixes #207.
2014-06-21 14:44:28 -06:00
Ben Johnson b1dbd35da1 Fix merge-split regression.
This commit reverts merge-split and fixes the node.split() to do a multi-page split. This issue
caused problems with bulk loading because it would split into a small page and a very large page.
The very large page, in turn, would be an arbitrary size so when it was freed later it would be
difficult to reuse and would cause serious fragmentation issues.
2014-06-18 16:16:58 -06:00
Ben Johnson 4db99647eb Fix freelist rollback. 2014-06-13 15:50:47 -06:00
Ben Johnson 2321036228 Fix double free in merge-left rebalance.
This commit fixes a bug where deletions that caused merge-left rebalances were updating
the parent node which caused a node to "reappear" even after it had been deleted. This was
fixed in merge-right rebalances a while ago but merge-left is less frequent so it was
missed until now.

Many thanks to Jordan Sherer (@jsherer) for finding and reporting the bug.
2014-06-06 17:14:17 -06:00
Ben Johnson 54cad40a78 Fix merge-split spill issues. 2014-06-03 13:40:24 -06:00
Ben Johnson a96185e8b6 Allow split nodes to be merged with the next node.
This commit changes the node.split() functionality to check if the next node has
available space and, if so, it will merge the newly split keys into the next node.

Previously, keys could be continually put into the left side of a split causing that
first half to split off small right side nodes. This was especially problematic with
databases with a high fill percent.
2014-06-02 15:26:58 -06:00
yosssi a9189ddefb Fix `ExampleBucket_Put` to use `db.View` instead of `db.Update`. 2014-05-31 11:22:50 +09: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 e728eb90da Minor stats fixes. 2014-05-14 12:06:31 -06:00
Martin Kobetic 0716cdaec8 tweaks 2014-05-12 19:33:53 +00:00
Martin Kobetic 0dbfa3f08a merge inline branch into leaf branch 2014-05-12 18:22:45 +00:00
Martin Kobetic deffc06a05 fix inline bucket stats 2014-05-12 17:29:16 +00:00
Martin Kobetic c4ad027df7 aggregate bucket stats recursively and add stats to cmd 2014-05-09 20:50:58 +00:00
Ben Johnson 0966dde0d4 Fix bucket free. 2014-05-07 10:37:50 -06:00
Ben Johnson 55e71b0902 Add inline bucket support.
This commit adds support for writing small buckets directly inline to their value in
their parent's leaf node. Previously, subbuckets would simply have a bucket header
stored in their parent bucket which pointed to the root page. This required that
every bucket use at least a single page. This has a high overhead for buckets with
only one or two small items.

Inline buckets checks subbuckets to see if they only have a small amount of data
(about 1kb) and no subbuckets. If these conditions are met then the bucket's root
node is written to a fake page which is simply a pointer to the end of the bucket's
header.

Fixes #124.
2014-05-05 16:39:55 -06:00
Ben Johnson 25fea2fd9f Refactor split/spill. 2014-05-03 16:21:28 -06:00
Kevin Gillette 1879d88c43 Printf's %s and %q do the right thing with []byte; removed string conversion. 2014-04-25 15:38:42 -06:00
Ben Johnson 0567eea5f5 Change to BucketStats and Bucket.Stats().
This commit pluralizes the BucketStat type to be BucketStats. This makes it
more consistent with the other Stats() calls. This commit also changes the
return type to a struct instead of a pointer.

Finally, this commit adds documentation to the fields of BucketStats.
2014-04-22 15:11:49 -06:00
Martin Kobetic a02ddf402b rename MaxDepth to Depth 2014-04-22 20:32:09 +00:00
Martin Kobetic 03cb096230 skip space assertions for incompatible page size 2014-04-22 20:29:37 +00:00
Martin Kobetic 4245fd9c4e allign naming with MemStats 2014-04-22 20:22:18 +00:00
Martin Kobetic 62592ec840 moar tweaks 2014-04-22 20:18:09 +00:00
Martin Kobetic 9c1b768185 update stats test 2014-04-22 18:34:34 +00:00
Ben Johnson 2505b9a7dc Return bucket from CreateBucket() functions.
This commit changes the API for:

    Tx.CreateBucket()
    Tx.CreateBucketIfNotExists()
    Bucket.CreateBucket()
    Bucket.CreateBucketIfNotExists()

These functions now return the *Bucket and error instead of just the error.
2014-04-15 23:45:06 -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 686b6a3341 Add performance counters.
This commit adds performance counters for each transaction which are rolled
up to the database level on each commit/rollback. Counters are meant to be
a very fast way to track what is going on in the database. A few timers are
also added in areas where the time.Now() overhead is not noticible.

The DB.Stat() function is now deprecated since the `bolt` CLI now performs
similar functions.

Fixes #108.
2014-04-02 16:03:03 -06:00
Ben Johnson 7f2de9f17a Add DB.Check(). 2014-03-29 14:22:32 -06:00
Ben Johnson f8ad21bad3 Make DB/Tx API more consistent.
I consolidated the DB.Tx() and DB.RWTx() calls into a single
DB.Begin(writable bool) call. This is more consistent with the
database/sql library.

I also changed the DB.Do() and DB.With() call to DB.Update() and
DB.View(), respectively. This is more intuitive and more inline with
other database verbiage.
2014-03-24 11:43:06 -06:00
Ben Johnson 59fde2f664 Error refactoring.
Fixed up a few error issues and refactored out the Error type.
2014-03-24 08:31:15 -06:00
Ben Johnson 3cc959fb1a Remove ease-of-use functions from the DB type.
Functions such as DB.Put(), DB.Get(), and DB.Delete() were originally
added to be easy to use, however, after implementing Bolt in multiple
projects I have found these ease-of-use functions useless. Nearly
every use case requires multiple calls in a single transaction.

Using the DB ease of use functions turned out to be an antipattern.
2014-03-21 09:52:01 -06:00
Tommi Virtanen ed909b43ea Skip long-running tests with go test -short 2014-03-13 17:10:33 -07: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 a544249dd8 Refactor Bucket. 2014-02-23 08:32:53 -07:00
Ben Johnson 3b2fd8f2d3 Revert "Refactor Transaction/Bucket API."
This reverts commit 1ad2b99f28.
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 1028d571d8 Bucket stats. 2014-02-21 09:20:45 -07:00