// addValueToMap adds the given value to the map on which the method is run.
// This allows us to merge maps such as {foo: {bar: baz}} and {foo: {baz: faz}}
// into {foo: {bar: baz, baz: faz}}.
36
func addValueToMap(keys []string, value interface{}, target map[string]interface{}) {
	next := target

	for i := range keys {
		// If we are on last key set or overwrite the val.
		if i == len(keys)-1 {
			next[keys[i]] = value
			break
		}

		if iface, ok := next[keys[i]]; ok {
			switch typed := iface.(type) {
			case map[string]interface{}:
				// If we already had a map inside, keep
				// stepping through.
				next = typed
			default:
				// If we didn't, then overwrite value
				// with a map and iterate with that.
				m := map[string]interface{}{}
				next[keys[i]] = m
				next = m
			}
			continue
		}

		// Otherwise, it wasn't present, so make it and step
		// into.
		m := map[string]interface{}{}
		next[keys[i]] = m
		next = m
	}
}
149487
func (pr *PilosaRecord) AddVal(field string, value int64) {
	pr.Vals = append(pr.Vals, Val{Field: field, Value: value})
}
72620
func (mm *methodManager) AddFunction(
	name string, function interface{}, option ...Options) {
	if name == "" {
		panic("name can't be empty")
	}
	if function == nil {
		panic("function can't be nil")
	}
	f, ok := function.(reflect.Value)
	if !ok {
		f = reflect.ValueOf(function)
	}
	if f.Kind() != reflect.Func {
		panic("function must be func or bound method")
	}
	var options Options
	if len(option) > 0 {
		options = option[0]
	}
	if options.NameSpace != "" && name != "*" {
		name = options.NameSpace + "_" + name
	}
	mm.mmLocker.Lock()
	if mm.RemoteMethods[strings.ToLower(name)] == nil {
		mm.MethodNames = append(mm.MethodNames, name)
	}
	mm.RemoteMethods[strings.ToLower(name)] = &Method{f, options}
	mm.mmLocker.Unlock()
}
1335247
func (s *Segment) AddBoolAnnotation(key string, value bool) {
	s.addAnnotation(key, value)
}
1199516
func (m *NormMap) add(l int64) bool {
	assert(m.size <= 256) // once we add > 256 values, we nullify the map in addNumericField and don't use this strategy
	if l >= math.MinInt8 && l <= math.MaxInt8 {
		index := int(l + 128)
		if previous := m.singleByteRange[index]; previous < 0 {
			m.singleByteRange[index] = int16(m.size)
			m.size++
			return true
		}
		return false
	}
	if _, ok := m.other[l]; !ok {
		m.other[l] = int16(m.size)
		m.size++
		return true
	}
	return false
}
750452
func (ioctx *IOContext) CleanOmap(oid string) error {
	c_oid := C.CString(oid)
	defer C.free(unsafe.Pointer(c_oid))

	op := C.rados_create_write_op()
	C.rados_write_op_omap_clear(op)

	ret := C.rados_write_op_operate(op, ioctx.ioctx, c_oid, nil, 0)
	C.rados_release_write_op(op)

	return GetRadosError(int(ret))
}
1289794
func (m *MultiMap) ContainsValue(value interface{}) bool {
	for _, values := range m.m {
		for _, v := range values {
			if v == value {
				return true
			}
		}
	}
	return false
}
1230821
func (a Annotation) Add(key, value string) Annotation {
	a.setVal(key, value)
	return a
}
298399
func (s *IndicesRolloverService) AddMapping(typ string, mapping interface{}) *IndicesRolloverService {
	s.mappings[typ] = mapping
	return s
}
482061
func NewValueLocMap(c *ValueLocMapConfig) ValueLocMap {
	cfg := resolveValueLocMapConfig(c)
	locmap := &valueLocMap{workers: uint32(cfg.Workers)}
	// Minimum bits = 2 and count = 4 because the Page logic needs at least two
	// bits to work with, so it can split a page when needed.
	locmap.bits = 2
	count := uint32(4)
	est := uint32(cfg.PageSize / int(unsafe.Sizeof(valueLocMapEntry{})))
	for count < est {
		locmap.bits++
		count <<= 1
	}
	locmap.lowMask = count - 1
	// Minimum rootShift = 63 and count = 2 because the Roots logic needs at
	// least 1 bit to work with.
	locmap.rootShift = 63
	count = 2
	for count < uint32(cfg.Roots) {
		locmap.rootShift--
		count <<= 1
	}
	locmap.entriesLockMask = count - 1
	locmap.splitLevel = uint32(float64(uint32(1<<locmap.bits)) * cfg.SplitMultiplier)
	locmap.roots = make([]valueLocMapNode, count)
	for i := 0; i < len(locmap.roots); i++ {
		locmap.roots[i].highMask = uint64(1) << (locmap.rootShift - 1)
		locmap.roots[i].rangeStart = uint64(i) << locmap.rootShift
		locmap.roots[i].rangeStop = uint64(1)<<locmap.rootShift - 1 + locmap.roots[i].rangeStart
		// Local splitLevel should be a random +-10% to keep splits across a
		// distributed load from synchronizing and causing overall "split lag".
		locmap.roots[i].splitLevel = uint32(float64(locmap.splitLevel) + (rand.Float64()-.5)/5*float64(locmap.splitLevel))
		// Local mergeLevel should be a random percentage, up to 10% of the
		// splitLevel, to keep merges across a distributed load from
		// synchronizing and causing overall "merge lag".
		locmap.roots[i].mergeLevel = uint32(rand.Float64() / 10 * float64(locmap.splitLevel))
	}
	return locmap
}
1318276
func (arguments Arguments) unpackIntoMap(v map[string]interface{}, marshalledValues []interface{}) error {
	// Make sure map is not nil
	if v == nil {
		return fmt.Errorf("abi: cannot unpack into a nil map")
	}

	for i, arg := range arguments.NonIndexed() {
		v[arg.Name] = marshalledValues[i]
	}
	return nil
}
536539
func (m *ArrayMap) Add(value T) (key int) {
	if n := len(m.holes); n > 0 {
		key = m.holes[n-1]
		m.holes = m.holes[:n-1]
		m.data[key] = value
		m.validFlags.Set(key, true)
		return
	}
	key = len(m.data)
	m.data = append(m.data, value)
	m.validFlags.Push(true)
	return
}
687003
func AsMap(obj interface{}, includeGlobals bool) context.Map {
	return cm.AsMap(obj, includeGlobals)
}
211243
func (v *OrderedValues) Add(key, val []byte) {
	for i, j := range *v {
		if len(j) > 0 && bytes.Equal(j[0], key) {
			if len(val) > 0 {
				(*v)[i] = append((*v)[i], val)
			}
			return
		}
	}
	if len(val) == 0 {
		*v = append(*v, [][]byte{key})
	} else {
		*v = append(*v, [][]byte{key, val})
	}
}
1334388
func createValueFuncs(funcMap FuncMap) map[string]reflect.Value {
	m := make(map[string]reflect.Value)
	addValueFuncs(m, funcMap)
	return m
}
302360
func (dm *DocumentMapping) AddFieldMapping(fm *FieldMapping) {
	if dm.Fields == nil {
		dm.Fields = make([]*FieldMapping, 0)
	}
	dm.Fields = append(dm.Fields, fm)
}
68917
func (v retainKeysStrategy) MergeMap(e apply.MapElement) (apply.Result, error) {
	return apply.Result{}, fmt.Errorf("Cannot use retainkeys with map element %v", e.Name)
}