// Add inserts the identity into the identity manager. If the identity is
// already in the identity manager, the reference count for the identity is
// incremented.
765456
func (idm *IdentityManager) Add(identity *identity.Identity) {
	idm.mutex.Lock()
	defer idm.mutex.Unlock()
	idm.add(identity)
}
443333
func (o *queryM2M) Add(mds ...interface{}) (int64, error) {
	fi := o.fi
	mi := fi.relThroughModelInfo
	mfi := fi.reverseFieldInfo
	rfi := fi.reverseFieldInfoTwo

	orm := o.qs.orm
	dbase := orm.alias.DbBaser

	var models []interface{}
	var otherValues []interface{}
	var otherNames []string

	for _, colname := range mi.fields.dbcols {
		if colname != mfi.column && colname != rfi.column && colname != fi.mi.fields.pk.column &&
			mi.fields.columns[colname] != mi.fields.pk {
			otherNames = append(otherNames, colname)
		}
	}
	for i, md := range mds {
		if reflect.Indirect(reflect.ValueOf(md)).Kind() != reflect.Struct && i > 0 {
			otherValues = append(otherValues, md)
			mds = append(mds[:i], mds[i+1:]...)
		}
	}
	for _, md := range mds {
		val := reflect.ValueOf(md)
		if val.Kind() == reflect.Slice || val.Kind() == reflect.Array {
			for i := 0; i < val.Len(); i++ {
				v := val.Index(i)
				if v.CanInterface() {
					models = append(models, v.Interface())
				}
			}
		} else {
			models = append(models, md)
		}
	}

	_, v1, exist := getExistPk(o.mi, o.ind)
	if exist == false {
		panic(ErrMissPK)
	}

	names := []string{mfi.column, rfi.column}

	values := make([]interface{}, 0, len(models)*2)
	for _, md := range models {

		ind := reflect.Indirect(reflect.ValueOf(md))
		var v2 interface{}
		if ind.Kind() != reflect.Struct {
			v2 = ind.Interface()
		} else {
			_, v2, exist = getExistPk(fi.relModelInfo, ind)
			if exist == false {
				panic(ErrMissPK)
			}
		}
		values = append(values, v1, v2)

	}
	names = append(names, otherNames...)
	values = append(values, otherValues...)
	return dbase.InsertValue(orm.db, mi, true, names, values)
}
1214440
func (d *Sources) Add(ctx context.Context, source chronograf.Source) (chronograf.Source, error) {
	genID, err := d.IDs.Generate()
	if err != nil {
		d.Logger.
			WithField("component", "source").
			Error("Unable to generate ID")
		return chronograf.Source{}, err
	}

	id, err := strconv.Atoi(genID)
	if err != nil {
		d.Logger.
			WithField("component", "source").
			Error("Unable to convert ID")
		return chronograf.Source{}, err
	}

	source.ID = id

	file := sourceFile(d.Dir, source)
	if err = d.Create(file, source); err != nil {
		if err == chronograf.ErrSourceInvalid {
			d.Logger.
				WithField("component", "source").
				WithField("name", file).
				Error("Invalid Source: ", err)
		} else {
			d.Logger.
				WithField("component", "source").
				WithField("name", file).
				Error("Unable to write source:", err)
		}
		return chronograf.Source{}, err
	}
	return source, nil
}
1148771
func (err *MultiError) Add(errOrNil error) {
	if err != nil && errOrNil != nil {
		*err = append(*err, errOrNil)
	}
}
373702
func (i *Int32) Add(n int32) int32 {
	return atomic.AddInt32(&i.v, n)
}
11406
func (s *SeriesIDSet) Add(id SeriesID) {
	s.Lock()
	defer s.Unlock()
	s.AddNoLock(id)
}
153945
func Add(m types.Metric) {
	name := m.Info().Name

	lock.Lock()
	defer lock.Unlock()

	if _, ok := registry[name]; ok {
		panic(fmt.Sprintf("A metric with the name %q was already registered", name))
	}
	registry[name] = m
}
221782
func (s *SourcesStore) Add(ctx context.Context, src chronograf.Source) (chronograf.Source, error) {
	return s.AddF(ctx, src)
}
232301
func Add(vs ReaderWriter, vsOther Iterable) error {
	return vsOther.IterateValidators(func(id crypto.Addressable, power *big.Int) error {
		return AddPower(vs, id.GetPublicKey(), power)
	})
}
837879
func (s *messageStore) Add(id uint64) *Message {
	s.mutex.Lock()
	defer s.mutex.Unlock()

	if s.messages == nil {
		s.messages = make(map[uint64]*Message)
	}
	if _, ok := s.messages[id]; ok {
		panic(fmt.Sprintf("ID %v is not unique", id))
	}

	m := &Message{
		ID:           id,
		responseChan: make(chan Message),
	}
	s.messages[id] = m
	return m
}
1232834
func (s *ServiceCache) Add(e *common.Service, id string, data interface{}, local bool) error {
	s.Lock()
	defer s.Unlock()

	record := &entry{
		ports: e.Ports,
		data:  data,
		id:    id,
	}
	if err := s.addPorts(e, record, local); err != nil {
		return err
	}

	if err := s.addHostService(e, record, local); err != nil {
		return err
	}

	return s.addIPService(e, record, local)
}
1318141
func (idx *TruncIndex) Add(id string) error {
	idx.Lock()
	defer idx.Unlock()
	return idx.addID(id)
}
752273
func (this *Manidator) Add(dators ...Dator) {
	this.dators = append(this.dators, dators...)
}
984781
func (s *store) Add(key string, data interface{}) int {
	s.count++
	return s.root.add(key, data, s.count)
}
1027459
func (bg *balancerGroup) add(id string, weight uint32, builder balancer.Builder) {
	bg.mu.Lock()
	if _, ok := bg.idToBalancer[id]; ok {
		bg.mu.Unlock()
		grpclog.Warningf("balancer group: adding a balancer with existing ID: %s", id)
		return
	}
	bg.mu.Unlock()
	bgcc := &balancerGroupCC{
		id:    id,
		group: bg,
	}
	b := builder.Build(bgcc, balancer.BuildOptions{})
	bg.mu.Lock()
	bg.idToBalancer[id] = b
	bg.mu.Unlock()

	bg.pickerMu.Lock()
	bg.idToPickerState[id] = &pickerState{
		weight: weight,
		// Start everything in IDLE. It's doesn't affect the overall state
		// because we don't count IDLE when aggregating (as opposite to e.g.
		// READY, 1 READY results in overall READY).
		state: connectivity.Idle,
	}
	bg.pickerMu.Unlock()
}
172620
func (c *Client) Add(data interface{}) error {
	c.ensureTransmission()
	c.ensureBuilder()
	return c.builder.Add(data)
}
214782
func (s *MappingsStore) Add(ctx context.Context, o *chronograf.Mapping) (*chronograf.Mapping, error) {
	err := s.client.db.Update(func(tx *bolt.Tx) error {
		b := tx.Bucket(MappingsBucket)
		seq, err := b.NextSequence()
		if err != nil {
			return err
		}
		o.ID = fmt.Sprintf("%d", seq)

		v, err := internal.MarshalMapping(o)
		if err != nil {
			return err
		}

		return b.Put([]byte(o.ID), v)
	})

	if err != nil {
		return nil, err
	}

	return o, nil
}