MCPcopy
hub / github.com/etcd-io/bbolt / Bucket

Method Bucket

bucket.go:88–111  ·  bucket.go::Bucket.Bucket

Bucket retrieves a nested bucket by name. Returns nil if the bucket does not exist. The bucket instance is only valid for the lifetime of the transaction.

(name []byte)

Source from the content-addressed store, hash-verified

86// Returns nil if the bucket does not exist.
87// The bucket instance is only valid for the lifetime of the transaction.
88func (b *Bucket) Bucket(name []byte) *Bucket {
89 if b.buckets != nil {
90 if child := b.buckets[string(name)]; child != nil {
91 return child
92 }
93 }
94
95 // Move cursor to key.
96 c := b.Cursor()
97 k, v, flags := c.seek(name)
98
99 // Return nil if the key doesn't exist or it is not a bucket.
100 if !bytes.Equal(name, k) || (flags&common.BucketLeafFlag) == 0 {
101 return nil
102 }
103
104 // Otherwise create a bucket and cache it.
105 var child = b.openBucket(v)
106 if b.buckets != nil {
107 b.buckets[string(name)] = child
108 }
109
110 return child
111}
112
113// Helper method that re-interprets a sub-bucket value
114// from a parent into a Bucket

Callers 5

CreateBucketMethod · 0.95
DeleteBucketMethod · 0.95
recursivelyInspectMethod · 0.95

Calls 3

CursorMethod · 0.95
openBucketMethod · 0.95
seekMethod · 0.80

Tested by

no test coverage detected