// Assign multi file keys
10572
func (m *Master) AssignN(count int) (fid string, err error) {
	args := url.Values{}
	if count > 0 {
		args.Set("count", strconv.Itoa(count))
	}

	return m.AssignArgs(args)
}
1329469
func ShiftFiles(filesToShift []string, uidRange *UidRange) error {
	if uidRange.Shift != 0 && uidRange.Count != 0 {
		for _, f := range filesToShift {
			if err := os.Chown(f, int(uidRange.Shift), int(uidRange.Shift)); err != nil {
				return err
			}
		}
	}
	return nil
}
1084850
func assign(dst, src interface{}) (bool, error) {
	dstrv := indirectAlloc(reflect.ValueOf(dst))
	switch srct := src.(type) {
	case Float:
		if dstrv.Kind() != reflect.Float64 {
			return false, assignError(dstrv, src)
		}
		dstrv.SetFloat(float64(srct))
	case String:
		if dstrv.Kind() != reflect.String {
			return false, assignError(dstrv, src)
		}
		dstrv.SetString(string(srct))
	case Map:
		switch dstrv.Interface().(type) {
		case Map:
			dstrv.Set(reflect.ValueOf(srct))
		default:
			return false, assignError(dstrv, src)
		}
	case Slice:
		switch dstrv.Interface().(type) {
		case Slice:
			dstrv.Set(reflect.ValueOf(srct))
		default:
			return false, assignError(dstrv, src)
		}
	case Array:
		switch dstrv.Interface().(type) {
		case Array:
			dstrv.Set(reflect.ValueOf(srct))
		default:
			switch dstrv.Interface().(type) {
			case Array:
				dstrv.Set(reflect.ValueOf(srct))
			default:
				return false, assignError(dstrv, src)
			}
		}
	case Binary:
		if dstrv.Kind() != reflect.Slice && dstrv.Elem().Kind() != reflect.Uint8 {
			return false, assignError(dstrv, src)
		}
		dstrv.SetBytes([]byte(srct))
	case Undefined:
		// Nothing to do.
	case ObjectId:
		if dstrv.Kind() != reflect.Slice && dstrv.Elem().Kind() != reflect.Uint8 {
			return false, assignError(dstrv, src)
		}
		dstrv.SetBytes([]byte(srct))
	case Bool:
		if dstrv.Kind() != reflect.Bool {
			return false, assignError(dstrv, src)
		}
		dstrv.SetBool(bool(srct))
	case UTCDateTime:
		switch dstrv.Interface().(type) {
		case time.Time:
			// BSON time is milliseconds since unix epoch.
			// Go time is nanoseconds since unix epoch.
			dstrv.Set(reflect.ValueOf(time.Unix(0, int64(srct)*1e3)))
		default:
			if dstrv.Kind() != reflect.Int64 {
				return false, assignError(dstrv, src)
			}
			dstrv.SetInt(int64(srct))
		}
	case Null:
		// Nothing to do.
	case Regexp:
		switch dstrv.Interface().(type) {
		case Regexp:
			dstrv.Set(reflect.ValueOf(srct))
		default:
			return false, assignError(dstrv, src)
		}
	case DBPointer:
			switch dstrv.Interface().(type) {
			case DBPointer:
				dstrv.Set(reflect.ValueOf(srct))
			default:
				return false, assignError(dstrv, src)
			}
	case Javascript:
		if dstrv.Kind() != reflect.String {
			return false, assignError(dstrv, src)
		}
		dstrv.SetString(string(srct))
	case Symbol:
		if dstrv.Kind() != reflect.String {
			return false, assignError(dstrv, src)
		}
		dstrv.SetString(string(srct))
	case JavascriptScope:
		switch dstrv.Interface().(type) {
		case JavascriptScope:
			dstrv.Set(reflect.ValueOf(srct))
		default:
			return false, assignError(dstrv, src)
		}
	case Int32:
		if dstrv.Kind() != reflect.Int32 && dstrv.Kind() != reflect.Int64 {
			return false, assignError(dstrv, src)
		}
		dstrv.SetInt(int64(srct))
	case Timestamp:
		switch dstrv.Interface().(type) {
		case time.Time:
			// BSON time is milliseconds since unix epoch.
			// Go time is nanoseconds since unix epoch.
			dstrv.Set(reflect.ValueOf(time.Unix(0, int64(srct)*1e3)))
		default:
			if dstrv.Kind() != reflect.Int64 {
				return false, assignError(dstrv, src)
			}
			dstrv.SetInt(int64(srct))
		}
	case Int64:
		if dstrv.Kind() != reflect.Int64 {
			return false, assignError(dstrv, src)
		}
		dstrv.SetInt(int64(srct))
	case MinKey:
		// Nothing to do.
	case MaxKey:
		// Nothing to do.
	}
	return true, nil
}
172951
func (s *SingleLetter) Assign() (string, error) {
	s.Lock()
	defer s.Unlock()
	if len(s.devices) == 0 {
		return "", fmt.Errorf("No free device IDs")
	}
	device := s.devPrefix + s.devices[:1]
	s.devices = s.devices[1:]
	return device, nil
}
190684
func (broker *lxdBroker) AssignLXDProfiles(instId string, profilesNames []string, profilePosts []lxdprofile.ProfilePost) ([]string, error) {
	profileMgr, ok := broker.manager.(container.LXDProfileManager)
	if !ok {
		return []string{}, nil
	}
	return profileMgr.AssignLXDProfiles(instId, profilesNames, profilePosts)
}
70615
func (u *Unit) assignToMachine(m *Machine, unused bool) (err error) {
	buildTxn := func(attempt int) ([]txn.Op, error) {
		u, m := u, m // don't change outer vars
		if attempt > 0 {
			var err error
			u, err = u.st.Unit(u.Name())
			if err != nil {
				return nil, errors.Trace(err)
			}
			m, err = u.st.Machine(m.Id())
			if err != nil {
				return nil, errors.Trace(err)
			}
		}
		return u.assignToMachineOps(m, unused)
	}
	if err := u.st.db().Run(buildTxn); err != nil {
		return errors.Trace(err)
	}
	u.doc.MachineId = m.doc.Id
	m.doc.Clean = false
	return nil
}
823547
func (k *Keyring) installKeys(keys [][]byte, primaryKey []byte) {
	k.l.Lock()
	defer k.l.Unlock()

	newKeys := [][]byte{primaryKey}
	for _, key := range keys {
		if !bytes.Equal(key, primaryKey) {
			newKeys = append(newKeys, key)
		}
	}
	k.keys = newKeys
}
660178
func (a *decimal) Assign(v uint64) {
	var buf [24]byte

	// Write reversed decimal in buf.
	n := 0
	for v > 0 {
		v1 := v / 10
		v -= 10 * v1
		buf[n] = byte(v + '0')
		n++
		v = v1
	}

	// Reverse again to produce forward decimal in a.d.
	a.nd = 0
	for n--; n >= 0; n-- {
		a.d[a.nd] = buf[n]
		a.nd++
	}
	a.dp = a.nd
	trim(a)
}
952742
func (s *S3ContentLocationUpdate) SetFileKeyUpdate(v string) *S3ContentLocationUpdate {
	s.FileKeyUpdate = &v
	return s
}
1169958
func (g *Goon) PutMulti(src interface{}) ([]*datastore.Key, error) {
	keys, err := g.extractKeys(src, true) // allow incomplete keys on a Put request
	if err != nil {
		return nil, err
	}

	v := reflect.Indirect(reflect.ValueOf(src))
	mu := new(sync.Mutex)
	multiErr, any := make(appengine.MultiError, len(keys)), false
	goroutines := (len(keys)-1)/putMultiLimit + 1
	var wg sync.WaitGroup
	wg.Add(goroutines)
	for i := 0; i < goroutines; i++ {
		go func(i int) {
			defer wg.Done()
			lo := i * putMultiLimit
			hi := (i + 1) * putMultiLimit
			if hi > len(keys) {
				hi = len(keys)
			}
			rkeys, pmerr := datastore.PutMulti(g.Context, keys[lo:hi], v.Slice(lo, hi).Interface())
			if pmerr != nil {
				mu.Lock()
				any = true // this flag tells PutMulti to return multiErr later
				mu.Unlock()
				merr, ok := pmerr.(appengine.MultiError)
				if !ok {
					g.error(pmerr)
					for j := lo; j < hi; j++ {
						multiErr[j] = pmerr
					}
					return
				}
				copy(multiErr[lo:hi], merr)
			}

			for i, key := range keys[lo:hi] {
				if multiErr[lo+i] != nil {
					continue // there was an error writing this value, go to next
				}
				vi := v.Index(lo + i).Interface()
				if key.Incomplete() {
					g.setStructKey(vi, rkeys[i])
					keys[lo+i] = rkeys[i]
				}
				if g.inTransaction {
					mk := MemcacheKey(rkeys[i])
					g.txnCacheLock.Lock()
					g.toDeleteMC[mk] = true
					g.txnCacheLock.Unlock()
				}
			}
		}(i)
	}
	wg.Wait()

	// Memcache needs to be updated after the datastore to prevent a common race condition,
	// where a concurrent request will fetch the not-yet-updated data from the datastore
	// and populate memcache with it.
	if !g.inTransaction {
		var memkeys []string
		for _, key := range keys {
			if !key.Incomplete() {
				memkeys = append(memkeys, MemcacheKey(key))
			}
		}
		memcache.DeleteMulti(g.Context, memkeys)
	}

	if any {
		return keys, realError(multiErr)
	}
	return keys, nil
}
1126840
func (d *DiskEditValue) SetSSHKeys(keyIDs []string) {
	if d.SSHKeys == nil {
		d.SSHKeys = []*SSHKey{}
	}
	for _, keyID := range keyIDs {
		d.SSHKeys = append(d.SSHKeys, &SSHKey{Resource: NewResourceByStringID(keyID)})
	}
}
1371375
func (vmap *masterVNIDMap) assignVNID(networkClient networkclient.Interface, nsName string) error {
	vmap.lock.Lock()
	defer vmap.lock.Unlock()

	netid, exists, err := vmap.allocateNetID(nsName)
	if err != nil {
		return err
	}

	if !exists {
		// Create NetNamespace Object and update vnid map
		netns := &networkv1.NetNamespace{
			TypeMeta:   metav1.TypeMeta{Kind: "NetNamespace"},
			ObjectMeta: metav1.ObjectMeta{Name: nsName},
			NetName:    nsName,
			NetID:      netid,
		}
		if _, err := networkClient.NetworkV1().NetNamespaces().Create(netns); err != nil {
			if er := vmap.releaseNetID(nsName); er != nil {
				utilruntime.HandleError(er)
			}
			return err
		}
	}
	return nil
}
98888
func assign(gv reflect.Value, sv starlark.Value) error {
	assigner, err := getAssigner(gv.Type(), sv)
	if err != nil {
		return err
	}
	return assigner(gv)
}
159697
func (f *extFloat) AssignComputeBounds(mant uint64, exp int, neg bool, flt *floatInfo) (lower, upper extFloat) {
	f.mant = mant
	f.exp = exp - int(flt.mantbits)
	f.neg = neg
	if f.exp <= 0 && mant == (mant>>uint(-f.exp))<<uint(-f.exp) {
		// An exact integer
		f.mant >>= uint(-f.exp)
		f.exp = 0
		return *f, *f
	}
	expBiased := exp - flt.bias

	upper = extFloat{mant: 2*f.mant + 1, exp: f.exp - 1, neg: f.neg}
	if mant != 1<<flt.mantbits || expBiased == 1 {
		lower = extFloat{mant: 2*f.mant - 1, exp: f.exp - 1, neg: f.neg}
	} else {
		lower = extFloat{mant: 4*f.mant - 1, exp: f.exp - 2, neg: f.neg}
	}
	return
}
380601
func (s *S3ApplicationCodeLocationDescription) SetFileKey(v string) *S3ApplicationCodeLocationDescription {
	s.FileKey = &v
	return s
}
594766
func (c *Consumer) Assignment() (partitions []TopicPartition, err error) {
	var cParts *C.rd_kafka_topic_partition_list_t

	cErr := C.rd_kafka_assignment(c.handle.rk, &cParts)
	if cErr != C.RD_KAFKA_RESP_ERR_NO_ERROR {
		return nil, newError(cErr)
	}
	defer C.rd_kafka_topic_partition_list_destroy(cParts)

	partitions = newTopicPartitionsFromCparts(cParts)

	return partitions, nil
}
708563
func (fs *FileSet) TagKeyIterator(name []byte) TagKeyIterator {
	a := make([]TagKeyIterator, 0, len(fs.files))
	for _, f := range fs.files {
		itr := f.TagKeyIterator(name)
		if itr != nil {
			a = append(a, itr)
		}
	}
	return MergeTagKeyIterators(a...)
}