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

Method inlineable

bucket.go:806–828  ·  view source on GitHub ↗

inlineable returns true if a bucket is small enough to be written inline and if it contains no subbuckets. Otherwise, returns false.

()

Source from the content-addressed store, hash-verified

804// inlineable returns true if a bucket is small enough to be written inline
805// and if it contains no subbuckets. Otherwise, returns false.
806func (b *Bucket) inlineable() bool {
807 var n = b.rootNode
808
809 // Bucket must only contain a single leaf node.
810 if n == nil || !n.isLeaf {
811 return false
812 }
813
814 // Bucket is not inlineable if it contains subbuckets or if it goes beyond
815 // our threshold for inline bucket size.
816 var size = common.PageHeaderSize
817 for _, inode := range n.inodes {
818 size += common.LeafPageElementSize + uintptr(len(inode.Key())) + uintptr(len(inode.Value()))
819
820 if inode.Flags()&common.BucketLeafFlag != 0 {
821 return false
822 } else if size > b.maxInlineBucketSize() {
823 return false
824 }
825 }
826
827 return true
828}
829
830// Returns the maximum total size of a bucket to make it a candidate for inlining.
831func (b *Bucket) maxInlineBucketSize() uintptr {

Callers 1

spillMethod · 0.80

Calls 4

maxInlineBucketSizeMethod · 0.95
KeyMethod · 0.45
ValueMethod · 0.45
FlagsMethod · 0.45

Tested by

no test coverage detected