inlineable returns true if a bucket is small enough to be written inline and if it contains no subbuckets. Otherwise, returns false.
()
| 804 | // inlineable returns true if a bucket is small enough to be written inline |
| 805 | // and if it contains no subbuckets. Otherwise, returns false. |
| 806 | func (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. |
| 831 | func (b *Bucket) maxInlineBucketSize() uintptr { |
no test coverage detected