github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/internal/query/scanner/indexed.go (about) 1 package scanner 2 3 import ( 4 "fmt" 5 6 "github.com/ydb-platform/ydb-go-sdk/v3/internal/value" 7 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors" 8 ) 9 10 type IndexedScanner struct { 11 data *data 12 } 13 14 func Indexed(data *data) IndexedScanner { 15 return IndexedScanner{ 16 data: data, 17 } 18 } 19 20 func (s IndexedScanner) Scan(dst ...interface{}) error { 21 if len(dst) != len(s.data.columns) { 22 return xerrors.WithStackTrace( 23 fmt.Errorf("%w: %d != %d", 24 errIncompatibleColumnsAndDestinations, 25 len(dst), len(s.data.columns), 26 ), 27 ) 28 } 29 for i := range dst { 30 v := s.data.seekByIndex(i) 31 if err := value.CastTo(v, dst[i]); err != nil { 32 return xerrors.WithStackTrace(err) 33 } 34 } 35 36 return nil 37 }