diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-05-19 12:08:33 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-05-19 12:08:33 -0600 |
commit | 782ead0dbf3095d0e843c2036bf40cc8ecd9b4d1 (patch) | |
tree | 19babfefc617c7f82bc5dcfc287b3f4809a6623a /freelist_test.go | |
parent | Merge pull request #166 from benbjohnson/fill-percent (diff) | |
download | dedo-782ead0dbf3095d0e843c2036bf40cc8ecd9b4d1.tar.gz dedo-782ead0dbf3095d0e843c2036bf40cc8ecd9b4d1.tar.xz |
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.
Diffstat (limited to 'freelist_test.go')
-rw-r--r-- | freelist_test.go | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/freelist_test.go b/freelist_test.go index 2b321a4..00c71cf 100644 --- a/freelist_test.go +++ b/freelist_test.go @@ -36,15 +36,14 @@ func TestFreelist_release(t *testing.T) { // Ensure that a freelist can find contiguous blocks of pages. func TestFreelist_allocate(t *testing.T) { - f := &freelist{ids: []pgid{18, 13, 12, 9, 7, 6, 5, 4, 3}} - assert.Equal(t, f.allocate(2), pgid(12)) - assert.Equal(t, f.allocate(1), pgid(18)) - assert.Equal(t, f.allocate(3), pgid(5)) - assert.Equal(t, f.allocate(3), pgid(0)) - assert.Equal(t, f.allocate(2), pgid(3)) - assert.Equal(t, f.allocate(1), pgid(9)) - assert.Equal(t, f.allocate(0), pgid(0)) - assert.Equal(t, f.ids, []pgid{}) + f := &freelist{ids: []pgid{3, 4, 5, 6, 7, 9, 12, 13, 18}} + assert.Equal(t, 3, int(f.allocate(3))) + assert.Equal(t, 6, int(f.allocate(1))) + assert.Equal(t, 0, int(f.allocate(3))) + assert.Equal(t, 12, int(f.allocate(2))) + assert.Equal(t, 7, int(f.allocate(1))) + assert.Equal(t, 0, int(f.allocate(0))) + assert.Equal(t, []pgid{9, 18}, f.ids) } // Ensure that a freelist can deserialize from a freelist page. |