// Merges tables a and b provided the intersection of their columns (by name) are identical
335618
func mergeTables(tables ...*types.SQLTable) (*types.SQLTable, error) {
	table := &types.SQLTable{
		NotifyChannels: make(map[string][]string),
	}

	columns := make(map[string]*types.SQLTableColumn)
	notifications := make(map[string]map[string]struct{})

	for _, t := range tables {
		if t != nil {
			table.Name = t.Name
			for _, columnB := range t.Columns {
				if columnA, ok := columns[columnB.Name]; ok {
					if !columnA.Equals(columnB) {
						return nil, fmt.Errorf("cannot merge event class tables for %s because of "+
							"conflicting columns: %v and %v", t.Name, columnB, columnB)
					}
					// Just keep existing column from A - they match
				} else {
					// Add as new column
					table.Columns = append(table.Columns, columnB)
					columns[columnB.Name] = columnB
				}
			}
			for channel, columnNames := range t.NotifyChannels {
				for _, columnName := range columnNames {
					if notifications[channel] == nil {
						notifications[channel] = make(map[string]struct{})
					}
					notifications[channel][columnName] = struct{}{}
				}
			}
		}
	}

	// Merge notification channels requested by specs
	for channel, colMap := range notifications {
		for columnName := range colMap {
			table.NotifyChannels[channel] = append(table.NotifyChannels[channel], columnName)
		}
		sort.Strings(table.NotifyChannels[channel])
	}

	return table, nil
}
844165
func (s *JSONSchema) Merge(other *JSONSchema) {
	items := s.createMergeItems(other)
	for _, v := range items {
		if v.needed && v.b != nil {
			reflect.Indirect(reflect.ValueOf(v.a)).Set(reflect.ValueOf(v.b))
		}
	}

	for n, p := range other.Properties {
		if _, ok := s.Properties[n]; !ok {
			if s.Properties == nil {
				s.Properties = make(map[string]*JSONSchema)
			}
			s.Properties[n] = p
		}
	}

	for n, d := range other.Definitions {
		if _, ok := s.Definitions[n]; !ok {
			s.Definitions[n] = d
		}
	}

	for _, l := range other.Links {
		s.Links = append(s.Links, l)
	}

	for _, r := range other.Required {
		s.Required = append(s.Required, r)
	}
}
152626
func (ini *INI) Merge(from *INI, override bool) {
	for section, kv := range from.sections {
		for key, value := range kv {
			_, found := ini.SectionGet(section, key)
			if override || !found {
				ini.SectionSet(section, key, value)
			}
		}
	}
}
715000
func (c *Config) Merge(cfgs ...*Config) {
	for _, other := range cfgs {
		mergeConfig(c, other)
	}
}
1167401
func Merge(err ...error) error {
	var errs []error
	for _, e := range err {
		if e != nil {
			errs = append(errs, e)
		}
	}
	if len(errs) == 0 {
		return nil
	}
	return &merged{s: err}
}
1343566
func (verr *ValidationErrors) Merge(err *ValidationErrors) {
	if err == nil {
		return
	}
	verr.Errors = append(verr.Errors, err.Errors...)
	verr.Definitions = append(verr.Definitions, err.Definitions...)
}
461360
func Merge(mapA map[string]interface{}, mapB map[string]interface{}) map[string]interface{} {
	for k, v := range mapA {
		mapB[k] = v
	}

	return mapB
}
179468
func (ss *SearchStatus) Merge(other *SearchStatus) {
	ss.Total += other.Total
	ss.Failed += other.Failed
	ss.Successful += other.Successful
	if len(other.Errors) > 0 {
		if ss.Errors == nil {
			ss.Errors = make(map[string]error)
		}
		for otherIndex, otherError := range other.Errors {
			ss.Errors[otherIndex] = otherError
		}
	}
}
354852
func (a Annotation) Merge(as Annotation) Annotation {
	for k, v := range as {
		a.Add(k, v)
	}
	return a
}
611109
func (b *rescanBatch) merge(job *RescanJob) {
	if job.InitialSync {
		b.initialSync = true
	}
	b.addrs = append(b.addrs, job.Addrs...)

	for op, addr := range job.OutPoints {
		b.outpoints[op] = addr
	}

	if job.BlockStamp.Height < b.bs.Height {
		b.bs = job.BlockStamp
	}
	b.errChans = append(b.errChans, job.err)
}
791761
func merge(appliabels ...[]appliable) []appliable {
	all := []appliable{}

	for _, appl := range appliabels {
		all = append(all, appl...)
	}

	return all
}
441703
func (s *set) Merge(t Interface) {
	t.Each(func(item interface{}) bool {
		s.m[item] = keyExists
		return true
	})
}
1093028
func (h *HyperLogLog) Merge(other *HyperLogLog) error {
	if h.m != other.m {
		return errors.New("number of registers must match")
	}

	for j, r := range other.registers {
		if r > h.registers[j] {
			h.registers[j] = r
		}
	}

	return nil
}
1166932
func Merge(slices ...Slice) (Slice, error) {
	// Calculate overall length
	l := ValueLength(0)
	for _, s := range slices {
		if err := s.AssertType(Object); err != nil {
			return nil, WithStack(err)
		}
		byteSize, err := s.ByteSize()
		if err != nil {
			return nil, WithStack(err)
		}
		l += byteSize
	}

	if len(slices) == 1 {
		// Fast path, only 1 slice
		return slices[0], nil
	}

	// Create a buffer to hold all slices.
	b := NewBuilder(uint(l))
	keys := make(map[string]struct{})
	if err := b.OpenObject(); err != nil {
		return nil, WithStack(err)
	}
	for _, s := range slices {
		it, err := NewObjectIterator(s, true)
		if err != nil {
			return nil, WithStack(err)
		}
		for it.IsValid() {
			keySlice, err := it.Key(true)
			if err != nil {
				return nil, WithStack(err)
			}
			key, err := keySlice.GetString()
			if err != nil {
				return nil, WithStack(err)
			}
			if _, found := keys[key]; !found {
				// Record key
				keys[key] = struct{}{}

				// Fetch value
				value, err := it.Value()
				if err != nil {
					return nil, WithStack(err)
				}

				// Add key,value
				if err := b.addInternalKeyValue(key, NewSliceValue(value)); err != nil {
					return nil, WithStack(err)
				}
			}

			// Move to next field
			if err := it.Next(); err != nil {
				return nil, WithStack(err)
			}
		}
	}
	if err := b.Close(); err != nil {
		return nil, WithStack(err)
	}

	// Return slice
	result, err := b.Slice()
	if err != nil {
		return nil, WithStack(err)
	}
	return result, nil
}
1137955
func Merge(dst map[string]interface{}, srcs ...map[string]interface{}) (map[string]interface{}, error) {
	for _, src := range srcs {
		dst = mergeValues(src, dst)
	}
	return dst, nil
}
48032
func Merge(coll1, coll2 []string) []string {
	m := map[string]struct{}{}
	for _, v := range append(coll1, coll2...) {
		m[v] = struct{}{}
	}
	r := make([]string, 0, len(m))
	for k := range m {
		r = append(r, k)
	}
	return r
}
518046
func (s *Set) Merge(t Interface) {
	s.l.Lock()
	defer s.l.Unlock()

	t.Each(func(item interface{}) bool {
		s.m[item] = keyExists
		return true
	})
}