Source File
bucket.go
Belonging Package
go.etcd.io/bbolt/internal/common
package commonimport ()const BucketHeaderSize = int(unsafe.Sizeof(InBucket{}))// InBucket represents the on-file representation of a bucket.// This is stored as the "value" of a bucket key. If the bucket is small enough,// then its root page can be stored inline in the "value", after the bucket// header. In the case of inline buckets, the "root" will be 0.type InBucket struct {root Pgid // page id of the bucket's root-level pagesequence uint64 // monotonically incrementing, used by NextSequence()}func ( Pgid, uint64) InBucket {return InBucket{root: ,sequence: ,}}func ( *InBucket) () Pgid {return .root}func ( *InBucket) ( Pgid) {.root =}// InSequence returns the sequence. The reason why not naming it `Sequence`// is to avoid duplicated name as `(*Bucket) Sequence()`func ( *InBucket) () uint64 {return .sequence}func ( *InBucket) ( uint64) {.sequence =}func ( *InBucket) () {.sequence++}func ( *InBucket) ( []byte) *Page {return (*Page)(unsafe.Pointer(&[BucketHeaderSize]))}func ( *InBucket) () string {return fmt.Sprintf("<pgid=%d,seq=%d>", .root, .sequence)}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |