// baseScan returns a Scan struct with default values set.
181153
func baseScan(ctx context.Context, table []byte,
	options ...func(Call) error) (*Scan, error) {
	s := &Scan{
		base: base{
			table:    table,
			ctx:      ctx,
			resultch: make(chan RPCResult, 1),
		},
		baseQuery:     newBaseQuery(),
		scannerID:     math.MaxUint64,
		maxResultSize: DefaultMaxResultSize,
		numberOfRows:  DefaultNumberOfRows,
		reversed:      false,
	}
	err := applyOptions(s, options...)
	if err != nil {
		return nil, err
	}
	return s, nil
}
137145
func (c *context) scan(addr address, v reflect.Value, add bool) (extraSize uintptr) {
	size := v.Type().Size()
	var marked uintptr
	if addr.valid() {
		marked = c.seen.countRange(uintptr(addr), size)
		if marked == size {
			return 0 // Skip if we have already seen the whole object.
		}
		c.seen.markRange(uintptr(addr), size)
	}
	// fmt.Printf("%v: %v ⮑ (marked %d)\n", addr, v.Type(), marked)
	if c.tc.needScan(v.Type()) {
		extraSize = c.scanContent(addr, v)
	}
	size -= marked
	size += extraSize
	// fmt.Printf("%v: %v %d (add %v, size %d, marked %d, extra %d)\n", addr, v.Type(), size+extraSize, add, v.Type().Size(), marked, extraSize)
	if add {
		c.s.addValue(v, size)
	}
	return size
}
1089595
func (ba *BytesArray) Scan(value interface{}) (err error) {
	if value == nil {
		ba.BytesArray, ba.Valid = nil, false
		return
	}
	ba.Valid = true
	ba.BytesArray, err = BytesArrayScan(value)
	return
}
1304840
func Scan(v interface{}) Sizes {
	rv := reflect.ValueOf(v)
	if rv.Kind() != reflect.Ptr || rv.IsNil() {
		panic("value to scan must be non-nil pointer")
	}

	stopTheWorld("memsize scan")
	defer startTheWorld()

	ctx := newContext()
	ctx.scan(invalidAddr, rv, false)
	ctx.s.BitmapSize = ctx.seen.size()
	ctx.s.BitmapUtilization = ctx.seen.utilization()
	return *ctx.s
}
75291
func (c *Certs) Scan(src interface{}) error {
	bytes, ok := src.([]byte)
	if !ok {
		return error(errors.New("Scan source was not []bytes"))
	}

	certs := make(Certs)
	if err := json.Unmarshal(bytes, &certs); err != nil {
		return err
	}
	*c = certs

	return nil
}
849099
func (s *String) Scan(value interface{}) error {
	if value == nil {
		s.Chars, s.Valid = "", false
		return nil
	}
	s.Valid = true

	switch v := value.(type) {
	case []byte:
		s.Chars = string(v)
	case string:
		s.Chars = v
	default:
		return fmt.Errorf("ntypes: unsuported type (%T) passed to String.Scan", value)
	}

	return nil
}
922888
func (p *Polygon) Scan(src interface{}) error {
	b, ok := src.([]byte)
	if !ok {
		return ErrExpectedByteSlice{Value: src}
	}
	got, err := Unmarshal(b)
	if err != nil {
		return err
	}
	p1, ok := got.(*geom.Polygon)
	if !ok {
		return wkbcommon.ErrUnexpectedType{Got: p1, Want: p}
	}
	p.Polygon = p1
	return nil
}
211453
func (i *Iterator) Scan(r Record) error {
	if err := i.rows.MapScan(r); err != nil {
		return err
	}

	mapBytesToString(r)

	return nil
}
1272402
func (b *PostGISBox2D) Scan(value interface{}) error {
	if value == nil {
		*b = PostGISBox2D{}
		return nil
	}

	v, ok := value.([]byte)
	if !ok {
		return fmt.Errorf("PostGISBox2D.Scan: expected []byte, got %T (%v)", value, value)
	}

	n, err := fmt.Sscanf(string(v), "BOX(%f %f,%f %f)", &b.Min.Lon, &b.Min.Lat, &b.Max.Lon, &b.Max.Lat)
	if err != nil {
		return err
	}
	if n != 4 {
		return fmt.Errorf("PostGISBox2D.Scan: not enough params in the string: %v, %v != 4", v, n)
	}

	return nil
}
334355
func (cs *CachableSource) Scan() error {
	lc, err := NewLazySource(cs.root)
	if err != nil {
		return err
	}
	txn := iradix.New().Txn()
	err = cs.root.Walk(cs.root.Path(), func(path string, info os.FileInfo, err error) error {
		if err != nil {
			return errors.Wrapf(err, "failed to walk %s", path)
		}
		rel, err := Rel(cs.root, path)
		if err != nil {
			return err
		}
		h, err := lc.Hash(rel)
		if err != nil {
			return err
		}
		txn.Insert([]byte(rel), &fileInfo{sum: h})
		return nil
	})
	if err != nil {
		return err
	}
	cs.mu.Lock()
	defer cs.mu.Unlock()
	cs.tree = txn.Commit()
	return nil
}
309761
func NewScanRange(ctx context.Context, table, startRow, stopRow []byte,
	options ...func(Call) error) (*Scan, error) {
	scan, err := baseScan(ctx, table, options...)
	if err != nil {
		return nil, err
	}
	scan.startRow = startRow
	scan.stopRow = stopRow
	scan.key = startRow
	return scan, nil
}
363338
func (db *DB) ZRevScan(key []byte, cursor []byte, count int, inclusive bool, match string) ([]ScorePair, error) {
	return db.zScanGeneric(key, cursor, count, inclusive, match, true)
}
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)
}
21273
func (mls *MultiLineString) Scan(src interface{}) error {
	if src == nil {
		mls.MultiLineString = nil
		return nil
	}
	b, ok := src.([]byte)
	if !ok {
		return ErrExpectedByteSlice{Value: src}
	}
	got, err := Unmarshal(b)
	if err != nil {
		return err
	}
	mls1, ok := got.(*geom.MultiLineString)
	if !ok {
		return wkbcommon.ErrUnexpectedType{Got: mls1, Want: mls}
	}
	mls.MultiLineString = mls1
	return nil
}
1087783
func (s *GeometryScanner) Scan(d interface{}) error {
	s.Geometry = nil
	s.Valid = false

	if d == nil {
		return nil
	}

	data, ok := d.([]byte)
	if !ok {
		return ErrUnsupportedDataType
	}

	if data == nil {
		return nil
	}

	switch g := s.g.(type) {
	case nil:
		m, err := Unmarshal(data)
		if err != nil {
			return err
		}

		s.Geometry = m
		s.Valid = true
		return nil
	case *orb.Point:
		p, err := scanPoint(data)
		if err != nil {
			return err
		}

		*g = p
		s.Geometry = p
		s.Valid = true
		return nil
	case *orb.MultiPoint:
		p, err := scanMultiPoint(data)
		if err != nil {
			return err
		}

		*g = p
		s.Geometry = p
		s.Valid = true
		return nil
	case *orb.LineString:
		p, err := scanLineString(data)
		if err != nil {
			return err
		}

		*g = p
		s.Geometry = p
		s.Valid = true
		return nil
	case *orb.MultiLineString:
		p, err := scanMultiLineString(data)
		if err != nil {
			return err
		}

		*g = p
		s.Geometry = p
		s.Valid = true
		return nil
	case *orb.Ring:
		m, err := Unmarshal(data)
		if err != nil {
			return err
		}

		if p, ok := m.(orb.Polygon); ok && len(p) == 1 {
			*g = p[0]
			s.Geometry = p[0]
			s.Valid = true
			return nil
		}

		return ErrIncorrectGeometry
	case *orb.Polygon:
		m, err := scanPolygon(data)
		if err != nil {
			return err
		}

		*g = m
		s.Geometry = m
		s.Valid = true
		return nil
	case *orb.MultiPolygon:
		m, err := scanMultiPolygon(data)
		if err != nil {
			return err
		}

		*g = m
		s.Geometry = m
		s.Valid = true
		return nil
	case *orb.Collection:
		m, err := scanCollection(data)
		if err != nil {
			return err
		}

		*g = m
		s.Geometry = m
		s.Valid = true
		return nil
	case *orb.Bound:
		m, err := Unmarshal(data)
		if err != nil {
			return err
		}

		b := m.Bound()
		*g = b
		s.Geometry = b
		s.Valid = true
		return nil
	}

	return ErrIncorrectGeometry
}
961141
func (f *Float) Scan(src interface{}) error {
	b, ok := src.([]byte)
	if !ok {
		return errors.New("Scan source was not []byte")
	}
	str := string(b)
	*f = strToFloat(str)
	return nil
}
1190349
func (c *Client) SScan(set string, cursor string, options ...interface{}) (string, []string, error) {
	return c.scanCommandList("SSCAN", set, cursor, options...)
}