diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-01 09:42:11 -0800 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-01 09:42:11 -0800 |
commit | b2a78a23644bf7cddb81059bd19176ebbe44710e (patch) | |
tree | d6aa197560053444d76dce1bd198a584c051c7b9 /sys.go | |
parent | Merge pull request #4 from benbjohnson/api (diff) | |
parent | Add RWTransaction.Put(). (diff) | |
download | dedo-b2a78a23644bf7cddb81059bd19176ebbe44710e.tar.gz dedo-b2a78a23644bf7cddb81059bd19176ebbe44710e.tar.xz |
Merge pull request #5 from benbjohnson/put
Add RWTransaction.Put().
Diffstat (limited to 'sys.go')
-rw-r--r-- | sys.go | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -25,6 +25,16 @@ func (s *sys) get(key string) *bucket { return s.buckets[key] } +// getByRoot retrieves a bucket by root page id. +func (s *sys) getByRoot(pgid pgid) *bucket { + for _, b := range s.buckets { + if b.root == pgid { + return b + } + } + panic("root not found") +} + // put sets a new value for a bucket. func (s *sys) put(key string, b *bucket) { s.buckets[key] = b @@ -32,7 +42,9 @@ func (s *sys) put(key string, b *bucket) { // del deletes a bucket by name. func (s *sys) del(key string) { - delete(s.buckets, key) + if b := s.buckets[key]; b != nil { + delete(s.buckets, key) + } } // read initializes the data from an on-disk page. @@ -61,7 +73,8 @@ func (s *sys) read(p *page) { // Associate keys and buckets. for index, key := range keys { - s.buckets[key] = buckets[index] + b := &bucket{buckets[index].root} + s.buckets[key] = b } } |