Commit Graph

37 Commits (220b61e988ecf0a1667943fde98513583b8c1338)

Author SHA1 Message Date
Gyu-Ho Lee 42ab7c097f *: fix test print format 2016-01-08 00:31:45 -08:00
Ben Johnson 8b08bd4a80 test suite refactoring
This commit refactors the test suite to make it cleaner and to use the
standard testing library better. The `assert()`, `equals()`, and `ok()`
functions have been removed and some test names have been changed for
clarity.

No functionality has been changed.
2016-01-02 21:30:31 -07:00
Matt Layher 06cdcaad94 tx_test: add tests for two tx.ForEach cases 2015-05-12 16:55:19 -04:00
Ben Johnson 44e6192d2b Remove testify. 2014-07-26 17:17:03 -06:00
Ben Johnson ba6badc57f Move tests to a test package. 2014-07-26 15:11:47 -06:00
Ben Johnson ca2339d7cb Remove wrapping test closures. 2014-07-26 14:44:04 -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 2eaf8f7ce0 Add freelist assertion on every free().
This commit performs a check on the freelist pages to ensure that a double free can never happen.
2014-05-29 08:02:15 -06:00
Tommi Virtanen 394862d541 Do not attempt manual transaction rollback in Tx.Copy
The typical use these days is with a managed transaction, via db.View.

The first case (error when re-opening database file) is not tested;
it is harder to instrument, and I have other plans for it.
2014-05-28 10:15:49 -07:00
Ben Johnson b789691976 Add streaming check.
This commit changes Tx.Check() to return a channel through which check errors are returned. This allows
errors to be found before checking the entire data file.
2014-05-28 10:31:22 -06:00
Ben Johnson 7432bc341f Merge pull request #169 from benbjohnson/allocation
Fix freelist allocation direction.
2014-05-21 13:46:12 -06:00
Martin Kobetic 519d65228e move Copy and CopyFile from DB to Tx 2014-05-21 15:08:37 +00:00
Ben Johnson 12b36fe70c Fix freelist allocate(). 2014-05-19 14:11:32 -06:00
Ben Johnson 1f5fb0208b Add strict mode. 2014-05-14 18:08:55 -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 e3957cd0de Add Tx.Cursor().
This commit adds the Cursor() function to Tx. This allows iteration on the root bucket
in a similar way to iteration on other buckets.

Fixes #141.
2014-04-29 07:25:14 -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 a42d74da7e Add 'bolt bench'.
This commit adds a flexible benchmarking tool to the 'bolt' CLI. It allows
the user to separately specify the write mode and read mode (e.g. sequential
random, etc). It also allows the user to isolate profiling to either the
read or the writes.

Currently the bench tool only supports "seq" read and write modes. It also
does not support streaming of Bolt counters yet.

Fixes #95.

/cc @snormore
2014-04-18 22:15:31 -05:00
Steven Normore 71e91e24b0 move bench package to bench/cmd/bolt/bench 2014-04-18 21:44:48 -05:00
Steven Normore 105fece47a add bench sub-package 2014-04-18 21:44:47 -05:00
Steven Normore 97bd718b02 add benchmarks using Benchmark framework 2014-04-18 21:44:36 -05:00
Steven Normore fdde1bcb06 moar bench package 2014-04-18 21:44:27 -05: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 714436100a Merge branch 'master' into nested-keys
Conflicts:
	db_test.go
	tx_test.go
2014-04-11 14:31:34 -06: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
Martin Kobetic 86cc692872 make all benchmarks constant size and add multiple sizes 2014-04-08 20:53:54 +00:00
Ben Johnson feb84e39be Update cursor benchmark. 2014-04-04 13:08:40 -06:00
Ben Johnson 394e42e3eb Add Tx.OnCommit() handler.
This commit adds the ability to execute a function after a transaction has
successfully committed.
2014-04-04 07:59:24 -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 440b89418f Write freelist after each commit.
Well, this is embarassing. Somehow the freelist was never getting written after each commit.
This commit fixes that and fixes a small reporting issue with "bolt pages".
2014-03-31 08:52:19 -06:00
Ben Johnson d8e4cffa12 Fix bucket reclamation.
The bucket page is allocated separately from the rest of the pages but the old bucket pages were
not being added to the freelist. This change fixes that and adds a simple check for database
consistency. More advanced consistency checks can be added in the future.

Fixes #82.
2014-03-25 07:25:00 -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 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 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 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