// Create and chain a new bucket.
339835
func (ht *HashTable) growBucket(bucket int) {
	ht.EnsureSize(ht.BucketSize)
	lastBucketAddr := ht.lastBucket(bucket) * ht.BucketSize
	binary.PutVarint(ht.Buf[lastBucketAddr:lastBucketAddr+10], int64(ht.numBuckets))
	ht.Used += ht.BucketSize
	ht.numBuckets++
}
211175
func (c *CassandraBackend) bucket(key string) string {
	bs := c.buckets(key)
	return bs[len(bs)-1]
}
1193704
func createScopedManagerNS(ns walletdb.ReadWriteBucket, scope *KeyScope) error {
	// First, we'll create the scope bucket itself for this particular
	// scope.
	scopeKey := scopeToBytes(scope)
	scopeBucket, err := ns.CreateBucket(scopeKey[:])
	if err != nil {
		str := "failed to create sync bucket"
		return managerError(ErrDatabase, str, err)
	}

	_, err = scopeBucket.CreateBucket(acctBucketName)
	if err != nil {
		str := "failed to create account bucket"
		return managerError(ErrDatabase, str, err)
	}

	_, err = scopeBucket.CreateBucket(addrBucketName)
	if err != nil {
		str := "failed to create address bucket"
		return managerError(ErrDatabase, str, err)
	}

	// usedAddrBucketName bucket was added after manager version 1 release
	_, err = scopeBucket.CreateBucket(usedAddrBucketName)
	if err != nil {
		str := "failed to create used addresses bucket"
		return managerError(ErrDatabase, str, err)
	}

	_, err = scopeBucket.CreateBucket(addrAcctIdxBucketName)
	if err != nil {
		str := "failed to create address index bucket"
		return managerError(ErrDatabase, str, err)
	}

	_, err = scopeBucket.CreateBucket(acctNameIdxBucketName)
	if err != nil {
		str := "failed to create an account name index bucket"
		return managerError(ErrDatabase, str, err)
	}

	_, err = scopeBucket.CreateBucket(acctIDIdxBucketName)
	if err != nil {
		str := "failed to create an account id index bucket"
		return managerError(ErrDatabase, str, err)
	}

	_, err = scopeBucket.CreateBucket(metaBucketName)
	if err != nil {
		str := "failed to create a meta bucket"
		return managerError(ErrDatabase, str, err)
	}

	return nil
}
632737
func (s Storage) Create(bucket, key string, value []byte, nested ...string) Storage {
	return s.execute(bucket, key, value, nested, create)
}
1156995
func New(b *Bucketer) *Distribution {
	if b == nil {
		b = DefaultBucketer
	}
	return &Distribution{b: b, lastNonZeroBucket: -1}
}
475582
func (b *bucket) CreateObject(
	ctx context.Context,
	req *gcs.CreateObjectRequest) (o *gcs.Object, err error) {
	b.mu.Lock()
	defer b.mu.Unlock()

	o, err = b.createObjectLocked(req)
	return
}
1177583
func (l *Limiter) Bucket(name string) (b *Bucket, ok bool) {
	l.m.Lock()
	defer l.m.Unlock()
	b, ok = l.buckets[name]
	return
}
766545
func newBucket(cap int, period time.Duration) (b *Bucket) {
	b = &Bucket{
		cap:         cap,
		channelQuit: make(chan bool),
		count:       0,
		period:      period,
	}
	go b.tick()
	return
}
485611
func New(buckets []Bucket) *Continuum {
	var ret Continuum
	ret.Reset(buckets)
	return &ret
}
264592
func (g *GroupMod) AddBucket(bkt Bucket) {
	g.Buckets = append(g.Buckets, bkt)
}
1099213
func (b *Bucket) Bucket(name []byte) *Bucket {
	if b.buckets != nil {
		if child := b.buckets[string(name)]; child != nil {
			return child
		}
	}

	// Move cursor to key.
	c := b.Cursor()
	k, v, flags := c.seek(name)

	// Return nil if the key doesn't exist or it is not a bucket.
	if !bytes.Equal(name, k) || (flags&bucketLeafFlag) == 0 {
		return nil
	}

	// Otherwise create a bucket and cache it.
	var child = b.openBucket(v)
	if b.buckets != nil {
		b.buckets[string(name)] = child
	}

	return child
}
306346
func (t *Tx) Bucket(b []byte) (kv.Bucket, error) {
	return t.BucketFn(b)
}
610127
func (c *PeekCall) Bucket(bucket ...string) *PeekCall {
	c.urlParams_.SetMulti("bucket", append([]string{}, bucket...))
	return c
}
398158
func (b *Bucket) Put(key, value []byte) error {
	return b.PutFn(key, value)
}
171596
func (b *bucket) Bucket(key []byte) database.Bucket {
	// Ensure transaction state is valid.
	if err := b.tx.checkClosed(); err != nil {
		return nil
	}

	// Attempt to fetch the ID for the child bucket.  The bucket does not
	// exist if the bucket index entry does not exist.
	childID := b.tx.fetchKey(bucketIndexKey(b.id, key))
	if childID == nil {
		return nil
	}

	childBucket := &bucket{tx: b.tx}
	copy(childBucket.id[:], childID)
	return childBucket
}
76577
func (bm *bucketMeta) getOrCreateBucket(name []byte) *bucketMeta {
	bm.bucketsLock.Lock()
	defer bm.bucketsLock.Unlock()

	b, ok := bm.buckets[string(name)]
	if !ok {
		b = newBucketMeta()
		bm.buckets[string(name)] = b
	}
	return b
}
148875
func (c *BucketizedPoolConfiguration) NewBuckets() []Bucket {
	buckets := make([]Bucket, 0, len(c.Buckets))
	for _, bconfig := range c.Buckets {
		bucket := bconfig.NewBucket()
		buckets = append(buckets, bucket)
	}
	return buckets
}