diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-01-31 13:18:51 -0500 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-01 12:30:37 -0500 |
commit | 1a17a2cf1ee8b509dd00b7f29a01c13108acb2cc (patch) | |
tree | d6aa197560053444d76dce1bd198a584c051c7b9 /sys.go | |
parent | Merge pull request #4 from benbjohnson/api (diff) | |
download | dedo-1a17a2cf1ee8b509dd00b7f29a01c13108acb2cc.tar.gz dedo-1a17a2cf1ee8b509dd00b7f29a01c13108acb2cc.tar.xz |
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 } } |