// ScanTable performs a full table scan, ordered by the primary keys, if any
777704
func (ntts NonTransactionalTableScanner) ScanTable(ctx context.Context, td *tabletmanagerdatapb.TableDefinition) (*QueryResultReader, error) {
	return TableScan(ctx, ntts.wr.Logger(), ntts.wr.TopoServer(), ntts.tabletAlias, td)
}
1228333
func (set *IntSet) ScanColumn(colIdx int, colName string, rd types.Reader, n int) error {
	num, err := types.ScanInt64(rd, n)
	if err != nil {
		return err
	}

	setVal := *set
	if setVal == nil {
		*set = make(IntSet)
		setVal = *set
	}

	setVal[num] = struct{}{}
	return nil
}
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
}
1016742
func ScanRow(rows *sql.Rows, dst interface{}) error {
	return Default.ScanRow(rows, dst)
}
624011
func (c *Connector) Scan(ctx context.Context, ei *dosa.EntityInfo, minimumFields []string, token string, limit int) ([]map[string]dosa.FieldValue, string, error) {
	return c.Range(ctx, ei, map[string][]*dosa.Condition{}, minimumFields, token, limit)
}
651668
func (c *Connector) Scan(_ context.Context, ei *dosa.EntityInfo, minimumFields []string, token string, limit int) ([]map[string]dosa.FieldValue, string, error) {
	c.lock.RLock()
	defer c.lock.RUnlock()
	if c.data[ei.Def.Name] == nil {
		return []map[string]dosa.FieldValue{}, "", nil

	}
	entityRef := c.data[ei.Def.Name]
	allTheThings := make([]map[string]dosa.FieldValue, 0)

	// in order for Scan to be deterministic and continuable, we have
	// to sort the primary key references
	keys := make([]string, 0, len(entityRef))
	for key := range entityRef {
		keys = append(keys, key)
	}
	sort.Strings(keys)

	// if there was a token, decode it so we can determine the starting
	// partition key
	startPartKey, start, err := getStartingPoint(ei, token)
	if err != nil {
		return nil, "", errors.Wrapf(err, "Invalid token %s", token)
	}

	for _, key := range keys {
		if startPartKey != "" {
			// had a token, so we need to either partially skip or fully skip
			// depending on whether we found the token's partition key yet
			if key == startPartKey {
				// we reached the starting partition key, so stop skipping
				// future values, and add a portion of this one to the set
				startPartKey = ""
				found, offset := findInsertionPoint(ei.Def.Key, entityRef[key], start)
				if found {
					offset++
				}
				allTheThings = append(allTheThings, entityRef[key][offset:]...)
			} // else keep looking for this partition key
			continue
		}
		allTheThings = append(allTheThings, entityRef[key]...)
	}
	if len(allTheThings) == 0 {
		return []map[string]dosa.FieldValue{}, "", nil
	}
	// see if we need a token to return
	token = ""
	if len(allTheThings) > limit {
		token = makeToken(allTheThings[limit-1])
		allTheThings = allTheThings[:limit]
	}
	return copyRows(allTheThings), token, nil
}
417723
func (rs *ResultSet) Scanned() (int, *ResultSet, error) {
	cursor, err := rs.IntAt(0)
	if err != nil {
		return 0, nil, err
	}
	result, err := rs.ResultSetAt(1)
	return cursor, result, err
}
50990
func (s *Scanner) scanExponent(ch rune) rune {
	if ch == 'e' || ch == 'E' {
		ch = s.next()
		if ch == '-' || ch == '+' {
			ch = s.next()
		}
		ch = s.scanMantissa(ch)
	}
	return ch
}
155967
func (strings *Strings) ScanColumn(colIdx int, _ string, rd types.Reader, n int) error {
	b := make([]byte, n)
	_, err := io.ReadFull(rd, b)
	if err != nil {
		return err
	}

	*strings = append(*strings, internal.BytesToString(b))
	return nil
}
700339
func (s *DB) ScanRows(rows *sql.Rows, result interface{}) error {
	var (
		scope        = s.NewScope(result)
		clone        = scope.db
		columns, err = rows.Columns()
	)

	if clone.AddError(err) == nil {
		scope.scan(rows, columns, scope.Fields())
	}

	return clone.Error
}
24594
func (ctx *Context) ScanReader(r io.Reader) BasicScanner {
	return ctx.SetScanner(&ScanReader{sr: bufio.NewScanner(r)})
}
1085422
func (mvcc *MVCCLevelDB) ScanLock(startKey, endKey []byte, maxTS uint64) ([]*kvrpcpb.LockInfo, error) {
	mvcc.mu.RLock()
	defer mvcc.mu.RUnlock()

	iter, currKey, err := newScanIterator(mvcc.db, startKey, endKey)
	defer iter.Release()
	if err != nil {
		return nil, errors.Trace(err)
	}

	var locks []*kvrpcpb.LockInfo
	for iter.Valid() {
		dec := lockDecoder{expectKey: currKey}
		ok, err := dec.Decode(iter)
		if err != nil {
			return nil, errors.Trace(err)
		}
		if ok && dec.lock.startTS <= maxTS {
			locks = append(locks, &kvrpcpb.LockInfo{
				PrimaryLock: dec.lock.primary,
				LockVersion: dec.lock.startTS,
				Key:         currKey,
			})
		}

		skip := skipDecoder{currKey: currKey}
		_, err = skip.Decode(iter)
		if err != nil {
			return nil, errors.Trace(err)
		}
		currKey = skip.currKey
	}
	return locks, nil
}
1209734
func (resultsTable *ResultsTable) Scan(data interface{}) error {
	switch values := data.(type) {
	case []byte:
		return json.Unmarshal(values, resultsTable)
	case string:
		return resultsTable.Scan([]byte(values))
	default:
		return errors.New("unsupported data type for Qor Job error table")
	}
}
1029551
func (u *UUID) Scan(val interface{}) error {
	if s, ok := val.(string); ok {
		return u.SetString(s)
	}
	if b, ok := val.([]byte); ok {
		return u.ReadBytes(b)
	}

	return &ErrInvalidType{reflect.TypeOf(val)}
}
290971
func (kf *KeyFormat) ScanBytes(key []byte) [][]byte {
	segments := make([][]byte, len(kf.layout))
	n := kf.prefix.Length()
	for i, l := range kf.layout {
		if l == 0 {
			// Must be final variadic segment
			segments[i] = key[n:]
			return segments
		}
		n += l
		if n > len(key) {
			return segments[:i]
		}
		segments[i] = key[n-l : n]
	}
	return segments
}
158124
func (q *Query) Scan(dest ...interface{}) error {
	iter := q.Iter()
	if err := iter.checkErrAndNotFound(); err != nil {
		return err
	}
	iter.Scan(dest...)
	return iter.Close()
}
1215182
func (rs *Rows) ScanStructByName(dest interface{}) error {
	vv := reflect.ValueOf(dest)
	if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Struct {
		return errors.New("dest should be a struct's pointer")
	}

	cols, err := rs.Columns()
	if err != nil {
		return err
	}

	newDest := make([]interface{}, len(cols))
	var v EmptyScanner
	for j, name := range cols {
		f := fieldByName(vv.Elem(), rs.Mapper.Table2Obj(name))
		if f.IsValid() {
			newDest[j] = f.Addr().Interface()
		} else {
			newDest[j] = &v
		}
	}

	return rs.Rows.Scan(newDest...)
}