// NewValue creates a new value.
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
}
1046783
func (s *DeviceEvent) SetValue(v string) *DeviceEvent {
	s.Value = &v
	return s
}
581758
func NewKeyValue(cfg jsonconfig.Obj) (KeyValue, error) {
	var s KeyValue
	var err error
	typ := cfg.RequiredString("type")
	ctor, ok := ctors[typ]
	if typ != "" && !ok {
		return nil, fmt.Errorf("Invalid sorted.KeyValue type %q", typ)
	}
	if ok {
		s, err = ctor(cfg)
		if err != nil {
			we, ok := err.(NeedWipeError)
			if !ok {
				return nil, fmt.Errorf("error from %q KeyValue: %v", typ, err)
			}
			if err := cfg.Validate(); err != nil {
				return nil, err
			}
			we.Msg = fmt.Sprintf("error from %q KeyValue: %v", typ, err)
			return s, we
		}
	}
	return s, cfg.Validate()
}
825338
func (rs *ReducerStruct) NewVal() sophie.Sophier {
	if rs.NewValF != nil {
		return rs.NewValF()
	}
	return new(sophie.RawByteSlice)
}
358565
func (s *MapFilter) SetValue(v string) *MapFilter {
	s.Value = &v
	return s
}
965114
func (s *OptionSetting) SetValue(v string) *OptionSetting {
	s.Value = &v
	return s
}
259470
func NewKeyVal(key string, value datasync.LazyValue, rev int64) *KeyVal {
	return &KeyVal{key, value, rev}
}
1133026
func NewValueI8(v int8) Value {
	return Value{
		typ:     TI8,
		tnumber: uint64(v),
	}
}
640423
func (l *PacketList) insertValue(v Packet, at *PacketElement) *PacketElement {
	return l.insert(&PacketElement{Value: v}, at)
}
1276752
func (b *BoltCreator) NewKeyValue(id string) (pinterface.IKeyValue, error) {
	return NewKeyValue(b.db, id)
}
817185
func NewDatumValue(val *com_signalfx_metrics_protobuf.Datum) datapoint.Value {
	if val.DoubleValue != nil {
		return datapoint.NewFloatValue(val.GetDoubleValue())
	}
	if val.IntValue != nil {
		return datapoint.NewIntValue(val.GetIntValue())
	}
	return datapoint.NewStringValue(val.GetStrValue())
}
838140
func NewValueI64(v int64) Value {
	return Value{
		typ:     TI64,
		tnumber: uint64(v),
	}
}
1272815
func MustNewValue(v interface{}) *Value {
	ret, err := NewValue(v)
	if err != nil {
		panic(err)
	}
	return ret
}
1175561
func NewWith(convert StructOptions, value interface{}) Value {
	// quick return if we're passed an existing data.Value
	if val, ok := value.(Value); ok {
		return val
	}

	if value == nil {
		return Null{}
	}

	// see if value implements MarshalValue
	if mar, ok := value.(Marshaler); ok {
		return mar.MarshalValue()
	}

	// drill through pointers and interfaces to the underlying type
	var v = reflect.ValueOf(value)
	for v.Kind() == reflect.Interface || v.Kind() == reflect.Ptr {
		v = v.Elem()
	}
	if !v.IsValid() {
		return Null{}
	}

	if v.Type() == timeType {
		return String(v.Interface().(time.Time).Format(convert.TimeFormat))
	}

	switch v.Kind() {
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		return Int(v.Int())
	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
		return Int(v.Uint())
	case reflect.Float32, reflect.Float64:
		return Float(v.Float())
	case reflect.Bool:
		return Bool(v.Bool())
	case reflect.String:
		return String(v.String())
	case reflect.Slice:
		if v.IsNil() {
			return List(nil)
		}
		slice := []Value{}
		for i := 0; i < v.Len(); i++ {
			slice = append(slice, NewWith(convert, v.Index(i).Interface()))
		}
		return List(slice)
	case reflect.Map:
		var m = make(map[string]Value)
		for _, key := range v.MapKeys() {
			if key.Kind() != reflect.String {
				panic("map keys must be strings")
			}
			m[key.String()] = NewWith(convert, v.MapIndex(key).Interface())
		}
		return Map(m)
	case reflect.Struct:
		return convert.Data(v.Interface())
	default:
		panic(fmt.Errorf("unexpected data type: %T (%v)", value, value))
	}
}
1319640
func NewValueI32(v int32) Value {
	return Value{
		typ:     TI32,
		tnumber: uint64(v),
	}
}
36265
func (l *ItemList) insertValue(v Item, at *ItemElement) *ItemElement {
	return l.insert(&ItemElement{Value: v}, at)
}
1087259
func newEvent(typ string, value interface{}, prevValue interface{}) *event {
	return &event{
		typ:       typ,
		value:     value,
		prevValue: prevValue,
	}
}