const MaxKeySize … const MaxValueSize … const bucketHeaderSize … const minFillPercent … const maxFillPercent … const DefaultFillPercent … type Bucket … type bucket … // newBucket returns a new bucket associated with a transaction. func newBucket(tx *Tx) Bucket { … } // Tx returns the tx of the bucket. func (b *Bucket) Tx() *Tx { … } // Root returns the root of the bucket. func (b *Bucket) Root() pgid { … } // Writable returns whether the bucket is writable. func (b *Bucket) Writable() bool { … } // Cursor creates a cursor associated with the bucket. // The cursor is only valid as long as the transaction is open. // Do not use a cursor after the transaction is closed. func (b *Bucket) Cursor() *Cursor { … } // 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. func (b *Bucket) Bucket(name []byte) *Bucket { … } // Helper method that re-interprets a sub-bucket value // from a parent into a Bucket func (b *Bucket) openBucket(value []byte) *Bucket { … } // CreateBucket creates a new bucket at the given key and returns the new bucket. // Returns an error if the key already exists, if the bucket name is blank, or if the bucket name is too long. // The bucket instance is only valid for the lifetime of the transaction. func (b *Bucket) CreateBucket(key []byte) (*Bucket, error) { … } // CreateBucketIfNotExists creates a new bucket if it doesn't already exist and returns a reference to it. // Returns an error if the bucket name is blank, or if the bucket name is too long. // The bucket instance is only valid for the lifetime of the transaction. func (b *Bucket) CreateBucketIfNotExists(key []byte) (*Bucket, error) { … } // DeleteBucket deletes a bucket at the given key. // Returns an error if the bucket does not exist, or if the key represents a non-bucket value. func (b *Bucket) DeleteBucket(key []byte) error { … } // Get retrieves the value for a key in the bucket. // Returns a nil value if the key does not exist or if the key is a nested bucket. // The returned value is only valid for the life of the transaction. func (b *Bucket) Get(key []byte) []byte { … } // Put sets the value for a key in the bucket. // If the key exist then its previous value will be overwritten. // Supplied value must remain valid for the life of the transaction. // Returns an error if the bucket was created from a read-only transaction, if the key is blank, if the key is too large, or if the value is too large. func (b *Bucket) Put(key []byte, value []byte) error { … } // Delete removes a key from the bucket. // If the key does not exist then nothing is done and a nil error is returned. // Returns an error if the bucket was created from a read-only transaction. func (b *Bucket) Delete(key []byte) error { … } // Sequence returns the current integer for the bucket without incrementing it. func (b *Bucket) Sequence() uint64 { … } // SetSequence updates the sequence number for the bucket. func (b *Bucket) SetSequence(v uint64) error { … } // NextSequence returns an autoincrementing integer for the bucket. func (b *Bucket) NextSequence() (uint64, error) { … } // ForEach executes a function for each key/value pair in a bucket. // Because ForEach uses a Cursor, the iteration over keys is in lexicographical order. // If the provided function returns an error then the iteration is stopped and // the error is returned to the caller. The provided function must not modify // the bucket; this will result in undefined behavior. func (b *Bucket) ForEach(fn func(k, v []byte) error) error { … } func (b *Bucket) ForEachBucket(fn func(k []byte) error) error { … } // Stats returns stats on a bucket. func (b *Bucket) Stats() BucketStats { … } // forEachPage iterates over every page in a bucket, including inline pages. func (b *Bucket) forEachPage(fn func(*page, int, []pgid)) { … } // forEachPageNode iterates over every page (or node) in a bucket. // This also includes inline pages. func (b *Bucket) forEachPageNode(fn func(*page, *node, int)) { … } func (b *Bucket) _forEachPageNode(pgId pgid, depth int, fn func(*page, *node, int)) { … } // spill writes all the nodes for this bucket to dirty pages. func (b *Bucket) spill() error { … } // inlineable returns true if a bucket is small enough to be written inline // and if it contains no subbuckets. Otherwise returns false. func (b *Bucket) inlineable() bool { … } // Returns the maximum total size of a bucket to make it a candidate for inlining. func (b *Bucket) maxInlineBucketSize() uintptr { … } // write allocates and writes a bucket to a byte slice. func (b *Bucket) write() []byte { … } // rebalance attempts to balance all nodes. func (b *Bucket) rebalance() { … } // node creates a node from a page and associates it with a given parent. func (b *Bucket) node(pgId pgid, parent *node) *node { … } // free recursively frees all pages in the bucket. func (b *Bucket) free() { … } // dereference removes all references to the old mmap. func (b *Bucket) dereference() { … } // pageNode returns the in-memory node, if it exists. // Otherwise returns the underlying page. func (b *Bucket) pageNode(id pgid) (*page, *node) { … } type BucketStats … func (s *BucketStats) Add(other BucketStats) { … } // cloneBytes returns a copy of a given slice. func cloneBytes(v []byte) []byte { … }