// GenAutoTableIDKeyValue generates meta key by dbID, tableID and corresponding value by autoID.
979014
func (m *Meta) GenAutoTableIDKeyValue(dbID, tableID, autoID int64) (key, value []byte) {
	dbKey := m.dbKey(dbID)
	autoTableIDKey := m.autoTableIDKey(tableID)
	return m.txn.EncodeHashAutoIDKeyValue(dbKey, autoTableIDKey, autoID)
}
898165
func isValidTagKeyForTagValues(key string) bool {
	for _, k := range invalidTagKeysForTagValues {
		if k == key {
			return false
		}
	}
	return true
}
470684
func NewTagValueSeriesIDCache(c uint64) *TagValueSeriesIDCache {
	return &TagValueSeriesIDCache{
		cache:    map[string]map[string]map[string]*list.Element{},
		evictor:  list.New(),
		tracker:  newCacheTracker(newCacheMetrics(nil), nil),
		capacity: c,
	}
}
29446
func (tm *transactionManager) genIndexKeyByTrans(trans *transaction) string {
	return tm.genIndexKey(trans.data["q"].(string), trans.node.addr.String())
}
1106315
func (s *AutoScaleService) GetAutoScaleVmProfileByID(id string, opts ...OptionFunc) (*AutoScaleVmProfile, int, error) {
	p := &ListAutoScaleVmProfilesParams{}
	p.p = make(map[string]interface{})

	p.p["id"] = id

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return nil, -1, err
		}
	}

	l, err := s.ListAutoScaleVmProfiles(p)
	if err != nil {
		if strings.Contains(err.Error(), fmt.Sprintf(
			"Invalid parameter id value=%s due to incorrect long value format, "+
				"or entity does not exist", id)) {
			return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
		}
		return nil, -1, err
	}

	if l.Count == 0 {
		return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
	}

	if l.Count == 1 {
		return l.AutoScaleVmProfiles[0], l.Count, nil
	}
	return nil, l.Count, fmt.Errorf("There is more then one result for AutoScaleVmProfile UUID: %s!", id)
}
175682
func (arc *ConfigFactory) GetValue(key string) cast.Value {
	if arc.initSuccess == false {
		return nil
	}

	var confValue cast.Value
	val := arc.GetConfigurationByKey(key)
	if val == nil {
		confValue = cast.NewValue(nil, errors.New("key does not exist"))
	} else {
		confValue = cast.NewValue(val, nil)
	}

	return confValue
}
1108278
func (g EcdhesKeyGenerate) KeyGenerate() (ByteSource, error) {
	priv, err := ecdsa.GenerateKey(g.pubkey.Curve, rand.Reader)
	if err != nil {
		return nil, errors.Wrap(err, "failed to generate key for ECDH-ES")
	}

	pubinfo := make([]byte, 4)
	binary.BigEndian.PutUint32(pubinfo, uint32(g.keysize)*8)

	z, _ := priv.PublicKey.Curve.ScalarMult(g.pubkey.X, g.pubkey.Y, priv.D.Bytes())
	kdf := concatkdf.New(crypto.SHA256, []byte(g.algorithm.String()), z.Bytes(), []byte{}, []byte{}, pubinfo, []byte{})
	kek := make([]byte, g.keysize)
	kdf.Read(kek)

	return ByteWithECPrivateKey{
		PrivateKey: priv,
		ByteKey:    ByteKey(kek),
	}, nil
}
558349
func (f Format) ValueForKey(key FormatKey) interface{} {
	switch key {
	case FormatItagKey:
		return f.Itag
	case FormatExtensionKey:
		return f.Extension
	case FormatResolutionKey:
		return f.Resolution
	case FormatVideoEncodingKey:
		return f.VideoEncoding
	case FormatAudioEncodingKey:
		return f.AudioEncoding
	case FormatAudioBitrateKey:
		return f.AudioBitrate
	default:
		if f.meta != nil {
			return f.meta[string(key)]
		}
		return nil
	}
}
420663
func NewSlaveDatabaseValue(values *SlaveDatabaseValue) *Database {
	db := &Database{
		// Appliance
		Appliance: &Appliance{
			// Class
			Class: "database",
			// Name
			propName: propName{Name: values.Name},
			// Description
			propDescription: propDescription{Description: values.Description},
			// TagsType
			propTags: propTags{
				// Tags
				Tags: values.Tags,
			},
			// Icon
			propIcon: propIcon{
				&Icon{
					// Resource
					Resource: values.Icon,
				},
			},
			// Plan
			//propPlanID: propPlanID{Plan: &Resource{ID: int64(values.Plan)}},
		},
		// Remark
		Remark: &DatabaseRemark{
			// ApplianceRemarkBase
			ApplianceRemarkBase: &ApplianceRemarkBase{
				// Servers
				Servers: []interface{}{""},
			},
			// DBConf
			DBConf: &DatabaseCommonRemarks{
				// Common
				Common: &DatabaseCommonRemark{
					// DatabaseName
					DatabaseName: values.DatabaseName,
					// DatabaseVersion
					DatabaseVersion: values.DatabaseVersion,
				},
			},
			// Plan
			propPlanID: propPlanID{Plan: &Resource{ID: int64(values.Plan)}},
		},
		// Settings
		Settings: &DatabaseSettings{
			// DBConf
			DBConf: &DatabaseSetting{
				// Common
				Common: &DatabaseCommonSetting{
					// DefaultUser
					DefaultUser: values.DefaultUser,
					// UserPassword
					UserPassword: values.UserPassword,
				},
				// Replication
				Replication: &DatabaseReplicationSetting{
					Model:     DatabaseReplicationModelAsyncReplica,
					Appliance: &struct{ ID string }{ID: fmt.Sprintf("%d", values.MasterApplianceID)},
					IPAddress: values.MasterIPAddress,
					Port:      values.MasterPort,
					User:      "replica",
					Password:  values.ReplicaPassword,
				},
			},
		},
	}

	db.Remark.Switch = &ApplianceRemarkSwitch{
		// ID
		ID: values.SwitchID,
	}
	db.Remark.Network = &DatabaseRemarkNetwork{
		// NetworkMaskLen
		NetworkMaskLen: values.MaskLen,
		// DefaultRoute
		DefaultRoute: values.DefaultRoute,
	}

	db.Remark.Servers = []interface{}{
		map[string]interface{}{"IPAddress": values.IPAddress1},
	}

	return db
}
1078801
func (v *Type) GetKeyValueSliceType() (o *TypePair) {
	if v != nil && v.KeyValueSliceType != nil {
		return v.KeyValueSliceType
	}

	return
}
1063126
func (s *DeviceEKStorage) keyToGeneration(mctx libkb.MetaContext, key string) keybase1.EkGeneration {
	prefix, err := s.keyPrefix(mctx)
	if err != nil {
		mctx.Debug("keyToGeneration: unable to get keyPrefix: %v", err)
		return -1
	}
	if !strings.HasPrefix(key, prefix) || !strings.HasSuffix(key, deviceEKSuffix) {
		mctx.Debug("keyToGeneration: key missing prefix: %v or suffix: %s", prefix, deviceEKSuffix)
		return -1
	}

	key = strings.TrimSuffix(key, deviceEKSuffix)
	parts := strings.Split(key, prefix)
	if len(parts) != 2 {
		mctx.Debug("keyToGeneration: unexpected parts: %v, prefix: %v", parts)
		return -1
	}
	g, err := strconv.ParseUint(parts[1], 10, 64)
	if err != nil {
		mctx.Debug("keyToGeneration: unable to parseUint: %v", err)
		return -1
	}
	return keybase1.EkGeneration(g)
}
1313167
func (tm *transactionManager) genIndexKey(queryType, address string) string {
	return strings.Join([]string{queryType, address}, ":")
}
307189
func nodeKey(id ID) []byte {
	key := append([]byte(dbNodePrefix), id[:]...)
	key = append(key, ':')
	key = append(key, dbDiscoverRoot...)
	return key
}
598592
func (t EnumType) GetDefaultValue() interface{} {
	// manual default value has precedence over first value in list of allowed
	// values
	if t.DefaultValue != nil {
		return t.DefaultValue
	}
	// fallback to first permitted element
	if len(t.Values) > 0 {
		return t.Values[0]
	}
	return nil
}
696421
func (g *GPGKey) GetPrimaryKeyID() int64 {
	if g == nil || g.PrimaryKeyID == nil {
		return 0
	}
	return *g.PrimaryKeyID
}
1010892
func (client *BaseClient) AutoID() (string, error) {
	client.topicManager.locker.RLock()
	if client.id != "" {
		client.topicManager.locker.RUnlock()
		return client.id, nil
	}
	client.topicManager.locker.RUnlock()
	client.topicManager.locker.Lock()
	defer client.topicManager.locker.Unlock()
	if client.id != "" {
		return client.id, nil
	}
	results, err := client.Invoke("#", nil, &autoIDSettings)
	if err != nil {
		return "", err
	}
	client.id = results[0].String()
	return client.id, nil
}
573620
func (bldr *fooBarQueryBuilder) KeysOnly() *fooBarQueryBuilder {
	bldr.q = bldr.q.KeysOnly()
	if bldr.plugin != nil {
		bldr.plugin.KeysOnly()
	}
	return bldr
}