//See Database#ScanVals
161601
func (me *TxDatabase) ScanVals(i interface{}, query string, args ...interface{}) error {
	exec := newCrudExec(me, nil, query, args...)
	return exec.ScanVals(i)
}
1291930
func (macdl *MACDLineSeries) GetValues(index int) (x float64, y float64) {
	if macdl.InnerSeries == nil {
		return
	}
	if macdl.ema1 == nil && macdl.ema2 == nil {
		macdl.ensureEMASeries()
	}

	x, _ = macdl.InnerSeries.GetValues(index)

	_, emav1 := macdl.ema1.GetValues(index)
	_, emav2 := macdl.ema2.GetValues(index)

	y = emav2 - emav1
	return
}
1183384
func (d *Database) Scan(rows *sql.Rows, dst interface{}) error {
	// get the list of struct fields
	data, err := getFields(reflect.TypeOf(dst))
	if err != nil {
		return err
	}

	// get the sql columns
	columns, err := rows.Columns()
	if err != nil {
		return err
	}

	return d.scanRow(data, rows, dst, columns)
}
1221957
func (args Args) WalkValues(field string, op func(value string) error) error {
	if _, ok := args.fields[field]; !ok {
		return nil
	}
	for v := range args.fields[field] {
		if err := op(v); err != nil {
			return err
		}
	}
	return nil
}
356021
func scanPrimitiveVal(src []byte, dest reflect.Value) error {
	if len(src) == 0 {
		return nil // skip blanks
	}
	switch dest.Kind() {
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		srcInt, err := strconv.ParseInt(string(src), 10, 0)
		if err != nil {
			return fmt.Errorf("zoom: could not convert %s to int", string(src))
		}
		dest.SetInt(srcInt)
	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
		srcUint, err := strconv.ParseUint(string(src), 10, 0)
		if err != nil {
			return fmt.Errorf("zoom: could not convert %s to uint", string(src))
		}
		dest.SetUint(srcUint)

	case reflect.Float32, reflect.Float64:
		srcFloat, err := strconv.ParseFloat(string(src), 64)
		if err != nil {
			return fmt.Errorf("zoom: could not convert %s to float", string(src))
		}
		dest.SetFloat(srcFloat)
	case reflect.Bool:
		srcBool, err := strconv.ParseBool(string(src))
		if err != nil {
			return fmt.Errorf("zoom: could not convert %s to bool", string(src))
		}
		dest.SetBool(srcBool)
	case reflect.String:
		dest.SetString(string(src))
	case reflect.Slice, reflect.Array:
		// Slice or array of bytes
		dest.SetBytes(src)
	default:
		return fmt.Errorf("zoom: don't know how to scan primitive type: %T", src)
	}
	return nil
}
349809
func (d *dbBase) ReadValues(q dbQuerier, qs *querySet, mi *modelInfo, cond *Condition, exprs []string, container interface{}, tz *time.Location) (int64, error) {

	var (
		maps  []Params
		lists []ParamsList
		list  ParamsList
	)

	typ := 0
	switch v := container.(type) {
	case *[]Params:
		d := *v
		if len(d) == 0 {
			maps = d
		}
		typ = 1
	case *[]ParamsList:
		d := *v
		if len(d) == 0 {
			lists = d
		}
		typ = 2
	case *ParamsList:
		d := *v
		if len(d) == 0 {
			list = d
		}
		typ = 3
	default:
		panic(fmt.Errorf("unsupport read values type `%T`", container))
	}

	tables := newDbTables(mi, d.ins)

	var (
		cols  []string
		infos []*fieldInfo
	)

	hasExprs := len(exprs) > 0

	Q := d.ins.TableQuote()

	if hasExprs {
		cols = make([]string, 0, len(exprs))
		infos = make([]*fieldInfo, 0, len(exprs))
		for _, ex := range exprs {
			index, name, fi, suc := tables.parseExprs(mi, strings.Split(ex, ExprSep))
			if suc == false {
				panic(fmt.Errorf("unknown field/column name `%s`", ex))
			}
			cols = append(cols, fmt.Sprintf("%s.%s%s%s %s%s%s", index, Q, fi.column, Q, Q, name, Q))
			infos = append(infos, fi)
		}
	} else {
		cols = make([]string, 0, len(mi.fields.dbcols))
		infos = make([]*fieldInfo, 0, len(exprs))
		for _, fi := range mi.fields.fieldsDB {
			cols = append(cols, fmt.Sprintf("T0.%s%s%s %s%s%s", Q, fi.column, Q, Q, fi.name, Q))
			infos = append(infos, fi)
		}
	}

	where, args := tables.getCondSQL(cond, false, tz)
	groupBy := tables.getGroupSQL(qs.groups)
	orderBy := tables.getOrderSQL(qs.orders)
	limit := tables.getLimitSQL(mi, qs.offset, qs.limit)
	join := tables.getJoinSQL()

	sels := strings.Join(cols, ", ")

	query := fmt.Sprintf("SELECT %s FROM %s%s%s T0 %s%s%s%s%s", sels, Q, mi.table, Q, join, where, groupBy, orderBy, limit)

	d.ins.ReplaceMarks(&query)

	rs, err := q.Query(query, args...)
	if err != nil {
		return 0, err
	}
	refs := make([]interface{}, len(cols))
	for i := range refs {
		var ref interface{}
		refs[i] = &ref
	}

	defer rs.Close()

	var (
		cnt     int64
		columns []string
	)
	for rs.Next() {
		if cnt == 0 {
			cols, err := rs.Columns()
			if err != nil {
				return 0, err
			}
			columns = cols
		}

		if err := rs.Scan(refs...); err != nil {
			return 0, err
		}

		switch typ {
		case 1:
			params := make(Params, len(cols))
			for i, ref := range refs {
				fi := infos[i]

				val := reflect.Indirect(reflect.ValueOf(ref)).Interface()

				value, err := d.convertValueFromDB(fi, val, tz)
				if err != nil {
					panic(fmt.Errorf("db value convert failed `%v` %s", val, err.Error()))
				}

				params[columns[i]] = value
			}
			maps = append(maps, params)
		case 2:
			params := make(ParamsList, 0, len(cols))
			for i, ref := range refs {
				fi := infos[i]

				val := reflect.Indirect(reflect.ValueOf(ref)).Interface()

				value, err := d.convertValueFromDB(fi, val, tz)
				if err != nil {
					panic(fmt.Errorf("db value convert failed `%v` %s", val, err.Error()))
				}

				params = append(params, value)
			}
			lists = append(lists, params)
		case 3:
			for i, ref := range refs {
				fi := infos[i]

				val := reflect.Indirect(reflect.ValueOf(ref)).Interface()

				value, err := d.convertValueFromDB(fi, val, tz)
				if err != nil {
					panic(fmt.Errorf("db value convert failed `%v` %s", val, err.Error()))
				}

				list = append(list, value)
			}
		}

		cnt++
	}

	switch v := container.(type) {
	case *[]Params:
		*v = maps
	case *[]ParamsList:
		*v = lists
	case *ParamsList:
		*v = list
	}

	return cnt, nil
}
130529
func (n *NullFloat32) Scan(value interface{}) (err error) {
	if value == nil {
		n.Float32, n.Valid = 0, false
		return
	}

	switch v := value.(type) {
	case float64:
		n.Float32, n.Valid = float32(v), true
		return
	case []uint8:
		if i, e := strconv.ParseFloat(string(v), 10); e == nil {
			n.Float32, n.Valid = float32(i), true
		}
		return
	}

	n.Valid = false
	return fmt.Errorf("null: can't convert %T to float32", value)
}
1191237
func (ps *PrefixScanner) Values() (values [][]byte, err error) {
	pre := ps.Prefix
	err = ps.db.View(func(tx *bolt.Tx) error {
		c := tx.Bucket(ps.BucketName).Cursor()
		for k, v := c.Seek(pre); bytes.HasPrefix(k, pre); k, v = c.Next() {
			values = append(values, v)
		}
		return nil
	})
	if err != nil {
		return nil, err
	}
	return values, err
}
449903
func (d *Database) SomeValues(src interface{}, columns []string) ([]interface{}, error) {
	data, err := getFields(reflect.TypeOf(src))
	if err != nil {
		return nil, err
	}
	structVal := reflect.ValueOf(src).Elem()

	var values []interface{}
	for _, name := range columns {
		field, present := data.fields[name]
		if !present {
			// write null to the database
			values = append(values, nil)

			if Debug {
				log.Printf("meddler.SomeValues: column [%s] not found in struct", name)
			}
			continue
		}

		saveVal, err := field.meddler.PreWrite(structVal.Field(field.index).Interface())
		if err != nil {
			return nil, fmt.Errorf("meddler.SomeValues: PreWrite error on column [%s]: %v", name, err)
		}
		values = append(values, saveVal)
	}

	return values, nil
}
334329
func (ms *MinSeries) GetValues(index int) (x, y float64) {
	ms.ensureMinValue()
	x, _ = ms.InnerSeries.GetValues(index)
	y = *ms.minValue
	return
}
389051
func (r *Request) QueryValues() url.Values {
	if r.Values == nil {
		if r.Request != nil {
			r.Values = r.Request.URL.Query()
		} else {
			r.Values = url.Values{}
		}
	}
	return r.Values
}
539007
func (v *Vars) ClearValues() {
	for _, s := range v.scopes {
		s.values = nil
	}
}
1339767
func (j *Jsonb) Scan(value interface{}) error {
	bytes, ok := value.([]byte)
	if !ok {
		return errors.New(fmt.Sprint("Failed to unmarshal JSONB value:", value))
	}

	return json.Unmarshal(bytes, j)
}
1016742
func ScanRow(rows *sql.Rows, dst interface{}) error {
	return Default.ScanRow(rows, dst)
}
607234
func (ema *EMASeries) GetValues(index int) (x, y float64) {
	if ema.InnerSeries == nil {
		return
	}
	if len(ema.cache) == 0 {
		ema.ensureCachedValues()
	}
	vx, _ := ema.InnerSeries.GetValues(index)
	x = vx
	y = ema.cache[index]
	return
}
1024929
func (ix *Reindexer) ScanFields(scanFields ...string) *Reindexer {
	ix.scanFields = scanFields
	return ix
}
548215
func (h *Histogram) RecordValues(v, n int64) error {
	idx := h.countsIndexFor(v)
	if idx < 0 || int(h.countsLen) <= idx {
		return fmt.Errorf("value %d is too large to be recorded", v)
	}
	h.counts[idx] += n
	h.totalCount += n

	return nil
}