// NewValueLocMap returns a new ValueLocMap instance using the config options
// given.
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
}
590557
func (c *Client) ValueDescriptorsByUomLabel(uomLabel string) (values []contract.ValueDescriptor, err error) {
	conn := c.Pool.Get()
	defer conn.Close()

	objects, err := getObjectsByRange(conn, db.ValueDescriptorCollection+":uomlabel:"+uomLabel, 0, -1)
	if err != nil {
		if err != redis.ErrNil {
			return values, err
		}
	}

	values = make([]contract.ValueDescriptor, len(objects))
	for i, in := range objects {
		err = unmarshalObject(in, &values[i])
		if err != nil {
			return values, err
		}
	}

	return values, nil
}
437776
func (v ElementBuildingVisitor) createMapValues(
	schemaFn schemaFn,
	meta apply.FieldMetaImpl,
	data apply.MapElementData) (map[string]apply.Element, error) {

	// Collate each key in the map
	values := map[string]apply.Element{}
	for _, key := range keysUnion(data.GetRecordedMap(), data.GetLocalMap(), data.GetRemoteMap()) {
		combined := apply.RawElementData{}
		if recorded, recordedSet := nilSafeLookup(key, data.GetRecordedMap()); recordedSet {
			combined.SetRecorded(recorded)
		}
		if local, localSet := nilSafeLookup(key, data.GetLocalMap()); localSet {
			combined.SetLocal(local)
		}
		if remote, remoteSet := nilSafeLookup(key, data.GetRemoteMap()); remoteSet {
			combined.SetRemote(remote)
		}

		// Create an item for the field
		field, err := v.getItem(schemaFn(key), key, combined)
		if err != nil {
			return nil, err
		}

		// Build the element for this field
		element, err := field.CreateElement(v)
		if err != nil {
			return nil, err
		}

		// Add the field element to the map
		values[key] = element
	}
	return values, nil
}
1321946
func Uint32ValueMap(src map[string]*uint32) map[string]uint32 {
	dst := make(map[string]uint32)
	for k, val := range src {
		if val != nil {
			dst[k] = *val
		}
	}
	return dst
}
1097038
func NewHashMap(opt Options) *HashMap {
	if opt.Metrics == nil {
		opt.Metrics = NewMetrics("", "", nil)
	}

	m := &HashMap{
		capacity:   pow2(opt.Capacity), // Limited to 2^64.
		loadFactor: opt.LoadFactor,
		tracker:    newRHHTracker(opt.Metrics, opt.Labels),
	}
	m.tracker.enabled = opt.MetricsEnabled

	m.alloc()
	return m
}
444921
func StringValueMap(src map[string]*string) map[string]string {
	dst := make(map[string]string)
	for k, val := range src {
		if val != nil {
			dst[k] = *val
		}
	}
	return dst
}
814494
func buildValueList(table *schema.Table, pkValues []sqltypes.PlanValue, bindVars map[string]*querypb.BindVariable) ([][]sqltypes.Value, error) {
	rows, err := sqltypes.ResolveRows(pkValues, bindVars)
	if err != nil {
		return nil, err
	}
	// Iterate by columns.
	for j := range pkValues {
		typ := table.GetPKColumn(j).Type
		for i := range rows {
			rows[i][j], err = sqltypes.Cast(rows[i][j], typ)
			if err != nil {
				return nil, err
			}
		}
	}
	return rows, nil
}
1096144
func FromMapElems(m interface{}) interface{} {
	inValue := reflect.ValueOf(m)
	outValue := reflect.MakeSlice(reflect.SliceOf(inValue.Type().Elem()), inValue.Len(), inValue.Len())
	for i, key := range inValue.MapKeys() {
		outValue.Index(i).Set(inValue.MapIndex(key))
	}
	return outValue.Interface()
}
760289
func NewValue(
	opts Options,
) Value {
	v := &value{
		opts:           opts,
		log:            opts.InstrumentOptions().Logger(),
		newUpdatableFn: opts.NewUpdatableFn(),
		getUpdateFn:    opts.GetUpdateFn(),
		processFn:      opts.ProcessFn(),
	}
	v.processWithLockFn = v.processWithLock
	return v
}
585963
func applicationConfigValue(key string, valueMap interface{}) (interface{}, error) {
	vm, ok := valueMap.(map[string]interface{})
	if !ok {
		return nil, errors.Errorf("unexpected application config value type %T for key %q", valueMap, key)
	}
	source, found := vm["source"]
	if !found {
		return nil, errors.Errorf("missing application config value 'source' for key %q", key)
	}
	if source != "user" {
		return nil, nil
	}
	value, found := vm["value"]
	if !found {
		return nil, errors.Errorf("missing application config value 'value'")
	}
	return value, nil
}
966946
func (oms *OnlyMapperStruct) NewVal() sophie.Sophier {
	if oms.NewValF != nil {
		return oms.NewValF()
	}
	return new(sophie.RawByteSlice)
}
1044900
func (opts *Options) valuesMap(m map[string]interface{}) (map[string]interface{}, error) {
	for _, skv := range opts.Values {
		if err := strvals.ParseInto(skv, m); err != nil {
			return nil, err
		}
	}
	return m, nil
}
1324691
func NewObjectValue(unindexed ...bool) Value {
	return Value{Object, nil, optionalBool(unindexed, false)}
}
1190266
func NewMVMap() *MVMap {
	m := new(MVMap)
	m.hashTable = make(map[uint64]entryAddr)
	m.entryStore.slices = [][]entry{make([]entry, 0, 64)}
	// Append the first empty entry, so the zero entryAddr can represent null.
	m.entryStore.put(entry{})
	m.dataStore.slices = [][]byte{make([]byte, 0, 1024)}
	return m
}
649188
func NewFuncMap() []template.FuncMap {
	return []template.FuncMap{map[string]interface{}{
		"GoVer": func() string {
			return strings.Title(runtime.Version())
		},
		"UseHTTPS": func() bool {
			return strings.HasPrefix(setting.AppURL, "https")
		},
		"AppName": func() string {
			return setting.AppName
		},
		"AppSubURL": func() string {
			return setting.AppSubURL
		},
		"AppURL": func() string {
			return setting.AppURL
		},
		"AppVer": func() string {
			return setting.AppVer
		},
		"AppDomain": func() string {
			return setting.Domain
		},
		"DisableGravatar": func() bool {
			return setting.DisableGravatar
		},
		"ShowFooterTemplateLoadTime": func() bool {
			return setting.ShowFooterTemplateLoadTime
		},
		"LoadTimes": func(startTime time.Time) string {
			return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms"
		},
		"AvatarLink":       tool.AvatarLink,
		"AppendAvatarSize": tool.AppendAvatarSize,
		"Safe":             Safe,
		"Sanitize":         bluemonday.UGCPolicy().Sanitize,
		"Str2HTML":         Str2HTML,
		"NewLine2br":       NewLine2br,
		"TimeSince":        tool.TimeSince,
		"RawTimeSince":     tool.RawTimeSince,
		"FileSize":         tool.FileSize,
		"Subtract":         tool.Subtract,
		"Add": func(a, b int) int {
			return a + b
		},
		"ActionIcon": ActionIcon,
		"DateFmtLong": func(t time.Time) string {
			return t.Format(time.RFC1123Z)
		},
		"DateFmtShort": func(t time.Time) string {
			return t.Format("Jan 02, 2006")
		},
		"List": List,
		"SubStr": func(str string, start, length int) string {
			if len(str) == 0 {
				return ""
			}
			end := start + length
			if length == -1 {
				end = len(str)
			}
			if len(str) < end {
				return str
			}
			return str[start:end]
		},
		"Join":              strings.Join,
		"EllipsisString":    tool.EllipsisString,
		"DiffTypeToStr":     DiffTypeToStr,
		"DiffLineTypeToStr": DiffLineTypeToStr,
		"Sha1":              Sha1,
		"ShortSHA1":         tool.ShortSHA1,
		"MD5":               tool.MD5,
		"ActionContent2Commits": ActionContent2Commits,
		"EscapePound":           EscapePound,
		"RenderCommitMessage":   RenderCommitMessage,
		"ThemeColorMetaTag": func() string {
			return setting.UI.ThemeColorMetaTag
		},
		"FilenameIsImage": func(filename string) bool {
			mimeType := mime.TypeByExtension(filepath.Ext(filename))
			return strings.HasPrefix(mimeType, "image/")
		},
		"TabSizeClass": func(ec *editorconfig.Editorconfig, filename string) string {
			if ec != nil {
				def := ec.GetDefinitionForFilename(filename)
				if def.TabWidth > 0 {
					return fmt.Sprintf("tab-size-%d", def.TabWidth)
				}
			}
			return "tab-size-8"
		},
	}}
}
487805
func CreateFromMap(m map[string]string) *Data {
	data := newData()
	for key, value := range m {
		data.Add(key, value)
	}
	return data
}
1045816
func MapToValues(m map[string]interface{}) url.Values {
	v := url.Values{}
	for key, value := range m {
		x := reflect.ValueOf(value)
		if x.Kind() == reflect.Array || x.Kind() == reflect.Slice {
			for i := 0; i < x.Len(); i++ {
				v.Add(key, ensureValueString(x.Index(i)))
			}
		} else {
			v.Add(key, ensureValueString(value))
		}
	}
	return v
}