// GetValue returns previous value associated with a change. For description of parameter and output
// values, see the comment in implemented interface datasync.ChangeEvent.
18948
func (ev *changePrev) GetValue(val proto.Message) (err error) {
	if ev.ProtoWatchResp.GetChangeType() != datasync.Delete {
		return ev.ProtoWatchResp.GetValue(val)
	}
	return nil
}
618286
func (e Enum) GetValue(key string) (interface{}, error) {
	for k, v := range e {
		if k == key {
			return v, nil
		}
	}
	return nil, fmt.Errorf("flagenum: Invalid value; must be one of [%s]", e.Choices())
}
732801
func (b *Buffer) GetValue(index int) float64 {
	effectiveIndex := (b.head + index) % len(b.array)
	return b.array[effectiveIndex]
}
849732
func (cs ConcatSeries) GetValue(index int) (x, y float64) {
	cursor := 0
	for _, s := range cs {
		if typed, isValuesProvider := s.(ValuesProvider); isValuesProvider {
			len := typed.Len()
			if index < cursor+len {
				x, y = typed.GetValues(index - cursor) //FENCEPOSTS.
				return
			}
			cursor += typed.Len()
		}
	}
	return
}
809220
func (list *SkipList) GetValue(key interface{}) (interface{}, bool) {
	element := list.Get(key)

	if element == nil {
		return nil, false
	}

	return element.Value, true
}
22247
func (r *Random) GetValue(_ int) float64 {
	if r.min != nil && r.max != nil {
		var delta float64

		if *r.max > *r.min {
			delta = *r.max - *r.min
		} else {
			delta = *r.min - *r.max
		}

		return *r.min + (r.rnd.Float64() * delta)
	} else if r.max != nil {
		return r.rnd.Float64() * *r.max
	} else if r.min != nil {
		return *r.min + (r.rnd.Float64())
	}
	return r.rnd.Float64()
}
1116643
func (e *Extractions) GetValue(key string) string {
	if val, ok := e.Extractions[key]; ok {
		return val.Value
	}
	return ""
}
269311
func (c *Client) GetValue(key string) (data []byte, found bool, revision int64, err error) {
	consulLogger.Debugf("GetValue: %q", key)
	pair, _, err := c.client.KV().Get(transformKey(key), nil)
	if err != nil {
		return nil, false, 0, err
	} else if pair == nil {
		return nil, false, 0, nil
	}

	return pair.Value, true, int64(pair.ModifyIndex), nil
}
211513
func (e *Event) GetPreviousValue(keys ...string) string {
	return getValue(e.Data.PreviousAttributes, keys)
}
891307
func (cm *ProtoConsumerMessage) GetValue(msg proto.Message) error {
	err := cm.serializer.Unmarshal(cm.ConsumerMessage.GetValue(), msg)
	if err != nil {
		return err
	}
	return nil
}
384251
func (dht *IpfsDHT) GetValue(ctx context.Context, key string, opts ...ropts.Option) (_ []byte, err error) {
	eip := logger.EventBegin(ctx, "GetValue")
	defer func() {
		eip.Append(loggableKey(key))
		if err != nil {
			eip.SetError(err)
		}
		eip.Done()
	}()

	// apply defaultQuorum if relevant
	var cfg ropts.Options
	if err := cfg.Apply(opts...); err != nil {
		return nil, err
	}
	opts = append(opts, Quorum(getQuorum(&cfg, defaultQuorum)))

	responses, err := dht.SearchValue(ctx, key, opts...)
	if err != nil {
		return nil, err
	}
	var best []byte

	for r := range responses {
		best = r
	}

	if ctx.Err() != nil {
		return best, ctx.Err()
	}

	if best == nil {
		return nil, routing.ErrNotFound
	}
	logger.Debugf("GetValue %v %v", key, best)
	return best, nil
}
1039400
func getParamValue(param string, dicts map[string]interface{}) (string, bool) {
	// split between inflectors and real param
	// real param and each inflector is seperated by `|`
	cleanParam, inflectors := func() (string, string) {
		arr := strings.SplitN(param, "|", 2)
		if len(arr) != 2 {
			return param, ""
		}
		return strings.TrimSpace(arr[0]), strings.TrimSpace(arr[1])
	}()

	// get the value
	val, ok := func() (string, bool) {
		// get from type parameters
		val, ok := dicts[cleanParam]
		if !ok {
			return "", false
		}
		return fmt.Sprintf("%v", val), true
	}()
	if !ok {
		return "", false
	}

	// inflect the value if needed
	if inflectors != "" {
		for _, inflector := range strings.Split(inflectors, "|") {
			inflector = strings.TrimSpace(inflector)
			var ok bool
			val, ok = doInflect(val, inflector)
			if !ok {
				log.Fatalf("invalid inflector " + inflector)
			}
		}
	}
	return val, true
}
127893
func (v *Value) Get(dirty ...bool) (value interface{}, err error) {
	if v.value != nil && time.Now().Before(v.next) {
		return v.value, nil
	}

	v.locker.Lock()
	defer v.locker.Unlock()

	if v.value != nil && time.Now().Before(v.next) {
		return v.value, nil
	}

	value, err = v.Load()
	if err == nil {
		ttl := v.TTL
		if ttl == 0 {
			ttl = time.Hour
		}
		v.value, v.next = value, time.Now().Add(ttl)
	} else {
		if v.value != nil && (len(dirty) > 0 && dirty[0]) {
			return v.value, nil
		}
	}
	return
}
957760
func GetTimeValue(ctx context.Context, v interface{}, tp byte, fsp int) (types.Datum, error) {
	return getTimeValue(ctx, v, tp, fsp)
}
1228068
func (ev *ChangeWatchResp) GetPrevValue(prevVal proto.Message) (prevExists bool, err error) {
	if ev.message.OperationType == PutDel_DEL {
		return false, err
	}

	return false, err //TODO prev value
}
1170980
func (kv *protoKeyVal) GetPrevValue(msg proto.Message) (prevValueExist bool, err error) {
	prevVal := kv.pair.GetPrevValue()
	if prevVal == nil {
		return false, nil
	}
	err = kv.serializer.Unmarshal(prevVal, msg)
	if err != nil {
		return true, err
	}
	return true, nil
}
1301609
func GetTimeValue(ctx sessionctx.Context, v interface{}, tp byte, fsp int) (d types.Datum, err error) {
	value := types.Time{
		Type: tp,
		Fsp:  fsp,
	}

	sc := ctx.GetSessionVars().StmtCtx
	switch x := v.(type) {
	case string:
		upperX := strings.ToUpper(x)
		if upperX == strings.ToUpper(ast.CurrentTimestamp) {
			defaultTime, err := getSystemTimestamp(ctx)
			if err != nil {
				return d, err
			}
			value.Time = types.FromGoTime(defaultTime.Truncate(time.Duration(math.Pow10(9-fsp)) * time.Nanosecond))
			if tp == mysql.TypeTimestamp || tp == mysql.TypeDatetime {
				err = value.ConvertTimeZone(time.Local, ctx.GetSessionVars().Location())
				if err != nil {
					return d, err
				}
			}
		} else if upperX == types.ZeroDatetimeStr {
			value, err = types.ParseTimeFromNum(sc, 0, tp, fsp)
			terror.Log(err)
		} else {
			value, err = types.ParseTime(sc, x, tp, fsp)
			if err != nil {
				return d, err
			}
		}
	case *driver.ValueExpr:
		switch x.Kind() {
		case types.KindString:
			value, err = types.ParseTime(sc, x.GetString(), tp, fsp)
			if err != nil {
				return d, err
			}
		case types.KindInt64:
			value, err = types.ParseTimeFromNum(sc, x.GetInt64(), tp, fsp)
			if err != nil {
				return d, err
			}
		case types.KindNull:
			return d, nil
		default:
			return d, errDefaultValue
		}
	case *ast.FuncCallExpr:
		if x.FnName.L == ast.CurrentTimestamp {
			d.SetString(strings.ToUpper(ast.CurrentTimestamp))
			return d, nil
		}
		return d, errDefaultValue
	case *ast.UnaryOperationExpr:
		// support some expression, like `-1`
		v, err := EvalAstExpr(ctx, x)
		if err != nil {
			return d, err
		}
		ft := types.NewFieldType(mysql.TypeLonglong)
		xval, err := v.ConvertTo(ctx.GetSessionVars().StmtCtx, ft)
		if err != nil {
			return d, err
		}

		value, err = types.ParseTimeFromNum(sc, xval.GetInt64(), tp, fsp)
		if err != nil {
			return d, err
		}
	default:
		return d, nil
	}
	d.SetMysqlTime(value)
	return d, nil
}