*: refactor decoder to avoid useless fieldType convert (#17632)

This commit is contained in:
lysu
2020-06-03 18:13:56 +08:00
committed by GitHub
parent ff24044bf7
commit 552e7709de
12 changed files with 79 additions and 153 deletions

View File

@ -2988,13 +2988,8 @@ func newRowDecoder(ctx sessionctx.Context, schema *expression.Schema, tbl *model
}
reqCols[idx] = rowcodec.ColInfo{
ID: col.ID,
Tp: int32(col.RetType.Tp),
Flag: int32(col.RetType.Flag),
Flen: col.RetType.Flen,
Decimal: col.RetType.Decimal,
Elems: col.RetType.Elems,
Collate: col.GetType().Collate,
VirtualGenCol: isGeneratedCol,
Ft: col.RetType,
}
}
defVal := func(i int, chk *chunk.Chunk) error {

View File

@ -119,9 +119,8 @@ func (m *memIndexReader) decodeIndexKeyValue(key, value []byte, tps []*types.Fie
col := m.table.Columns[idxCol.Offset]
colInfos = append(colInfos, rowcodec.ColInfo{
ID: col.ID,
Tp: int32(col.Tp),
Flag: int32(col.Flag),
IsPKHandle: m.table.PKIsHandle && mysql.HasPriKeyFlag(col.Flag),
Ft: rowcodec.FieldTypeFromModelColumn(col),
})
}
values, err := tablecodec.DecodeIndexKV(key, value, len(m.index.Columns), hdStatus, colInfos)
@ -170,11 +169,8 @@ func buildMemTableReader(us *UnionScanExec, tblReader *TableReaderExecutor) *mem
col := us.columns[i]
colInfo = append(colInfo, rowcodec.ColInfo{
ID: col.ID,
Tp: int32(col.Tp),
Flag: int32(col.Flag),
IsPKHandle: us.table.Meta().PKIsHandle && mysql.HasPriKeyFlag(col.Flag),
Collate: col.Collate,
Flen: col.Flen,
Ft: rowcodec.FieldTypeFromModelColumn(col),
})
}
@ -413,11 +409,8 @@ func (m *memIndexLookUpReader) getMemRows() ([][]types.Datum, error) {
col := m.columns[i]
colInfos = append(colInfos, rowcodec.ColInfo{
ID: col.ID,
Tp: int32(col.Tp),
Flag: int32(col.Flag),
IsPKHandle: m.table.Meta().PKIsHandle && mysql.HasPriKeyFlag(col.Flag),
Collate: col.Collate,
Flen: col.Flen,
Ft: rowcodec.FieldTypeFromModelColumn(col),
})
}
rd := rowcodec.NewByteDecoder(colInfos, []int64{-1}, nil, nil)

2
go.mod
View File

@ -20,7 +20,7 @@ require (
github.com/klauspost/cpuid v1.2.1
github.com/ngaut/pools v0.0.0-20180318154953-b7bc8c42aac7
github.com/ngaut/sync2 v0.0.0-20141008032647-7a24ed77b2ef
github.com/ngaut/unistore v0.0.0-20200602034536-a59a860991d8
github.com/ngaut/unistore v0.0.0-20200603091253-e0b717679796
github.com/opentracing/basictracer-go v1.0.0
github.com/opentracing/opentracing-go v1.1.0
github.com/pingcap/br v0.0.0-20200521085655-53201addd4ad

4
go.sum
View File

@ -377,8 +377,8 @@ github.com/ngaut/pools v0.0.0-20180318154953-b7bc8c42aac7 h1:7KAv7KMGTTqSmYZtNdc
github.com/ngaut/pools v0.0.0-20180318154953-b7bc8c42aac7/go.mod h1:iWMfgwqYW+e8n5lC/jjNEhwcjbRDpl5NT7n2h+4UNcI=
github.com/ngaut/sync2 v0.0.0-20141008032647-7a24ed77b2ef h1:K0Fn+DoFqNqktdZtdV3bPQ/0cuYh2H4rkg0tytX/07k=
github.com/ngaut/sync2 v0.0.0-20141008032647-7a24ed77b2ef/go.mod h1:7WjlapSfwQyo6LNmIvEWzsW1hbBQfpUO4JWnuQRmva8=
github.com/ngaut/unistore v0.0.0-20200602034536-a59a860991d8 h1:9RRf+Dqt0x+0ORKQ/CTwd2r0T782B/ovD4/6cLwXwkg=
github.com/ngaut/unistore v0.0.0-20200602034536-a59a860991d8/go.mod h1:9mpqZeS1CkNlgZwJ0LZXb+Qd7xVO5o55ngys7T1/oH8=
github.com/ngaut/unistore v0.0.0-20200603091253-e0b717679796 h1:mhOUY30ysXVcRuftTiFgbw//GERhoM/65u5jvr9LJ7s=
github.com/ngaut/unistore v0.0.0-20200603091253-e0b717679796/go.mod h1:9mpqZeS1CkNlgZwJ0LZXb+Qd7xVO5o55ngys7T1/oH8=
github.com/nicksnyder/go-i18n v1.10.0/go.mod h1:HrK7VCrbOvQoUAQ7Vpy7i87N7JZZZ7R2xBGjv0j365Q=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=

View File

@ -28,7 +28,6 @@ import (
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/chunk"
"github.com/pingcap/tidb/util/codec"
"github.com/pingcap/tidb/util/collate"
"github.com/pingcap/tidb/util/rowcodec"
"github.com/pingcap/tipb/go-tipb"
)
@ -148,10 +147,8 @@ func (h *rpcHandler) handleAnalyzeColumnsReq(req *coprocessor.Request, analyzeRe
col := columns[i]
colInfos[i] = rowcodec.ColInfo{
ID: col.ColumnId,
Tp: col.Tp,
Flag: col.Flag,
Ft: evalCtx.fieldTps[i],
IsPKHandle: col.GetPkHandle(),
Collate: collate.CollationID2Name(col.Collation),
}
}
defVal := func(i int) ([]byte, error) {

View File

@ -202,10 +202,8 @@ func (h *rpcHandler) buildTableScan(ctx *dagContext, executor *tipb.Executor) (*
col := columns[i]
colInfos[i] = rowcodec.ColInfo{
ID: col.ColumnId,
Tp: col.Tp,
Flag: col.Flag,
Ft: ctx.evalCtx.fieldTps[i],
IsPKHandle: col.GetPkHandle(),
Collate: collate.CollationID2Name(col.Collation),
}
}
defVal := func(i int) ([]byte, error) {
@ -269,10 +267,8 @@ func (h *rpcHandler) buildIndexScan(ctx *dagContext, executor *tipb.Executor) (*
col := columns[i]
colInfos = append(colInfos, rowcodec.ColInfo{
ID: col.ColumnId,
Tp: col.Tp,
Flag: col.Flag,
Ft: ctx.evalCtx.fieldTps[i],
IsPKHandle: col.GetPkHandle(),
Collate: collate.CollationID2Name(col.Collation),
})
}
e := &indexScanExec{

View File

@ -389,9 +389,8 @@ func createRowcodecColInfo(table *model.TableInfo, index *model.IndexInfo) []row
col := table.Columns[idxCol.Offset]
colInfos = append(colInfos, rowcodec.ColInfo{
ID: col.ID,
Tp: int32(col.Tp),
Flag: int32(col.Flag),
IsPKHandle: table.PKIsHandle && mysql.HasPriKeyFlag(col.Flag),
Ft: rowcodec.FieldTypeFromModelColumn(col),
})
}
return colInfos

View File

@ -368,13 +368,8 @@ func DecodeRowWithMapNew(b []byte, cols map[int64]*types.FieldType, loc *time.Lo
var idx int
for id, tp := range cols {
reqCols[idx] = rowcodec.ColInfo{
ID: id,
Tp: int32(tp.Tp),
Flag: int32(tp.Flag),
Flen: tp.Flen,
Decimal: tp.Decimal,
Elems: tp.Elems,
Collate: tp.Collate,
ID: id,
Ft: tp,
}
idx++
}

View File

@ -75,13 +75,8 @@ func BenchmarkDecode(b *testing.B) {
cols := make([]rowcodec.ColInfo, len(tps))
for i, tp := range tps {
cols[i] = rowcodec.ColInfo{
ID: colIDs[i],
Tp: int32(tp.Tp),
Flag: int32(tp.Flag),
Flen: tp.Flen,
Decimal: tp.Decimal,
Elems: tp.Elems,
Collate: tp.Collate,
ID: colIDs[i],
Ft: tp,
}
}
decoder := rowcodec.NewChunkDecoder(cols, []int64{-1}, nil, time.Local)

View File

@ -19,6 +19,8 @@ import (
"unsafe"
"github.com/pingcap/errors"
"github.com/pingcap/parser/model"
"github.com/pingcap/parser/types"
)
// CodecVer is the constant number that represent the new row format.
@ -228,3 +230,17 @@ func IsRowKey(key []byte) bool {
func IsNewFormat(rowData []byte) bool {
return rowData[0] == CodecVer
}
// FieldTypeFromModelColumn creates a types.FieldType from model.ColumnInfo.
// export for test case and CDC.
func FieldTypeFromModelColumn(col *model.ColumnInfo) *types.FieldType {
return &types.FieldType{
Tp: col.Tp,
Flag: col.Flag,
Flen: col.Flen,
Decimal: col.Decimal,
Elems: col.Elems,
Charset: col.Charset,
Collate: col.Collate,
}
}

View File

@ -46,16 +46,10 @@ func NewDecoder(columns []ColInfo, handleColIDs []int64, loc *time.Location) *de
// ColInfo is used as column meta info for row decoder.
type ColInfo struct {
ID int64
Tp int32
Flag int32
IsPKHandle bool
Flen int
Decimal int
Elems []string
Collate string
ID int64
IsPKHandle bool
VirtualGenCol bool
Ft *types.FieldType
}
// DatumMapDecoder decodes the row to datum map.
@ -112,7 +106,7 @@ func (decoder *DatumMapDecoder) tryDecodeHandleColumn(col *ColInfo, handle kv.Ha
return false
}
if col.ID == decoder.handleColIDs[0] {
if mysql.HasUnsignedFlag(uint(col.Flag)) {
if mysql.HasUnsignedFlag(col.Ft.Flag) {
row[col.ID] = types.NewUintDatum(uint64(handle.IntValue()))
} else {
row[col.ID] = types.NewIntDatum(handle.IntValue())
@ -124,9 +118,9 @@ func (decoder *DatumMapDecoder) tryDecodeHandleColumn(col *ColInfo, handle kv.Ha
func (decoder *DatumMapDecoder) decodeColDatum(col *ColInfo, colData []byte) (types.Datum, error) {
var d types.Datum
switch byte(col.Tp) {
switch col.Ft.Tp {
case mysql.TypeLonglong, mysql.TypeLong, mysql.TypeInt24, mysql.TypeShort, mysql.TypeTiny:
if mysql.HasUnsignedFlag(uint(col.Flag)) {
if mysql.HasUnsignedFlag(col.Ft.Flag) {
d.SetUint64(decodeUint(colData))
} else {
d.SetInt64(decodeInt(colData))
@ -146,7 +140,7 @@ func (decoder *DatumMapDecoder) decodeColDatum(col *ColInfo, colData []byte) (ty
}
d.SetFloat64(fVal)
case mysql.TypeVarString, mysql.TypeVarchar, mysql.TypeString:
d.SetString(string(colData), col.Collate)
d.SetString(string(colData), col.Ft.Collate)
case mysql.TypeBlob, mysql.TypeTinyBlob, mysql.TypeMediumBlob, mysql.TypeLongBlob:
d.SetBytes(colData)
case mysql.TypeNewDecimal:
@ -159,13 +153,13 @@ func (decoder *DatumMapDecoder) decodeColDatum(col *ColInfo, colData []byte) (ty
d.SetFrac(frac)
case mysql.TypeDate, mysql.TypeDatetime, mysql.TypeTimestamp:
var t types.Time
t.SetType(uint8(col.Tp))
t.SetFsp(int8(col.Decimal))
t.SetType(col.Ft.Tp)
t.SetFsp(int8(col.Ft.Decimal))
err := t.FromPackedUint(decodeUint(colData))
if err != nil {
return d, err
}
if byte(col.Tp) == mysql.TypeTimestamp && !t.IsZero() {
if col.Ft.Tp == mysql.TypeTimestamp && !t.IsZero() {
err = t.ConvertTimeZone(time.UTC, decoder.loc)
if err != nil {
return d, err
@ -175,23 +169,23 @@ func (decoder *DatumMapDecoder) decodeColDatum(col *ColInfo, colData []byte) (ty
case mysql.TypeDuration:
var dur types.Duration
dur.Duration = time.Duration(decodeInt(colData))
dur.Fsp = int8(col.Decimal)
dur.Fsp = int8(col.Ft.Decimal)
d.SetMysqlDuration(dur)
case mysql.TypeEnum:
// ignore error deliberately, to read empty enum value.
enum, err := types.ParseEnumValue(col.Elems, decodeUint(colData))
enum, err := types.ParseEnumValue(col.Ft.Elems, decodeUint(colData))
if err != nil {
enum = types.Enum{}
}
d.SetMysqlEnum(enum, col.Collate)
d.SetMysqlEnum(enum, col.Ft.Collate)
case mysql.TypeSet:
set, err := types.ParseSetValue(col.Elems, decodeUint(colData))
set, err := types.ParseSetValue(col.Ft.Elems, decodeUint(colData))
if err != nil {
return d, err
}
d.SetMysqlSet(set, col.Collate)
d.SetMysqlSet(set, col.Ft.Collate)
case mysql.TypeBit:
byteSize := (col.Flen + 7) >> 3
byteSize := (col.Ft.Flen + 7) >> 3
d.SetMysqlBit(types.NewBinaryLiteralFromUint(decodeUint(colData), byteSize))
case mysql.TypeJSON:
var j json.BinaryJSON
@ -199,7 +193,7 @@ func (decoder *DatumMapDecoder) decodeColDatum(col *ColInfo, colData []byte) (ty
j.Value = colData[1:]
d.SetMysqlJSON(j)
default:
return d, errors.Errorf("unknown type %d", col.Tp)
return d, errors.Errorf("unknown type %d", col.Ft.Tp)
}
return d, nil
}
@ -280,9 +274,9 @@ func (decoder *ChunkDecoder) tryAppendHandleColumn(colIdx int, col *ColInfo, han
}
func (decoder *ChunkDecoder) decodeColToChunk(colIdx int, col *ColInfo, colData []byte, chk *chunk.Chunk) error {
switch byte(col.Tp) {
switch col.Ft.Tp {
case mysql.TypeLonglong, mysql.TypeLong, mysql.TypeInt24, mysql.TypeShort, mysql.TypeTiny:
if mysql.HasUnsignedFlag(uint(col.Flag)) {
if mysql.HasUnsignedFlag(col.Ft.Flag) {
chk.AppendUint64(colIdx, decodeUint(colData))
} else {
chk.AppendInt64(colIdx, decodeInt(colData))
@ -309,9 +303,9 @@ func (decoder *ChunkDecoder) decodeColToChunk(colIdx int, col *ColInfo, colData
if err != nil {
return err
}
if col.Decimal != types.UnspecifiedLength && frac > col.Decimal {
if col.Ft.Decimal != types.UnspecifiedLength && frac > col.Ft.Decimal {
to := new(types.MyDecimal)
err := dec.Round(to, col.Decimal, types.ModeHalfEven)
err := dec.Round(to, col.Ft.Decimal, types.ModeHalfEven)
if err != nil {
return errors.Trace(err)
}
@ -320,13 +314,13 @@ func (decoder *ChunkDecoder) decodeColToChunk(colIdx int, col *ColInfo, colData
chk.AppendMyDecimal(colIdx, dec)
case mysql.TypeDate, mysql.TypeDatetime, mysql.TypeTimestamp:
var t types.Time
t.SetType(uint8(col.Tp))
t.SetFsp(int8(col.Decimal))
t.SetType(col.Ft.Tp)
t.SetFsp(int8(col.Ft.Decimal))
err := t.FromPackedUint(decodeUint(colData))
if err != nil {
return err
}
if byte(col.Tp) == mysql.TypeTimestamp && decoder.loc != nil && !t.IsZero() {
if col.Ft.Tp == mysql.TypeTimestamp && decoder.loc != nil && !t.IsZero() {
err = t.ConvertTimeZone(time.UTC, decoder.loc)
if err != nil {
return err
@ -336,23 +330,23 @@ func (decoder *ChunkDecoder) decodeColToChunk(colIdx int, col *ColInfo, colData
case mysql.TypeDuration:
var dur types.Duration
dur.Duration = time.Duration(decodeInt(colData))
dur.Fsp = int8(col.Decimal)
dur.Fsp = int8(col.Ft.Decimal)
chk.AppendDuration(colIdx, dur)
case mysql.TypeEnum:
// ignore error deliberately, to read empty enum value.
enum, err := types.ParseEnumValue(col.Elems, decodeUint(colData))
enum, err := types.ParseEnumValue(col.Ft.Elems, decodeUint(colData))
if err != nil {
enum = types.Enum{}
}
chk.AppendEnum(colIdx, enum)
case mysql.TypeSet:
set, err := types.ParseSetValue(col.Elems, decodeUint(colData))
set, err := types.ParseSetValue(col.Ft.Elems, decodeUint(colData))
if err != nil {
return err
}
chk.AppendSet(colIdx, set)
case mysql.TypeBit:
byteSize := (col.Flen + 7) >> 3
byteSize := (col.Ft.Flen + 7) >> 3
chk.AppendBytes(colIdx, types.NewBinaryLiteralFromUint(decodeUint(colData), byteSize))
case mysql.TypeJSON:
var j json.BinaryJSON
@ -360,7 +354,7 @@ func (decoder *ChunkDecoder) decodeColToChunk(colIdx int, col *ColInfo, colData
j.Value = colData[1:]
chk.AppendJSON(colIdx, j)
default:
return errors.Errorf("unknown type %d", col.Tp)
return errors.Errorf("unknown type %d", col.Ft.Tp)
}
return nil
}
@ -393,7 +387,7 @@ func (decoder *BytesDecoder) decodeToBytesInternal(outputOffset map[int64]int, h
values := make([][]byte, len(outputOffset))
for i := range decoder.columns {
col := &decoder.columns[i]
tp := fieldType2Flag(byte(col.Tp), uint(col.Flag)&mysql.UnsignedFlag == 0)
tp := fieldType2Flag(col.Ft.Tp, col.Ft.Flag&mysql.UnsignedFlag == 0)
colID := col.ID
offset := outputOffset[colID]
if decoder.tryDecodeHandle(values, offset, col, handle, cacheBytes) {
@ -435,7 +429,7 @@ func (decoder *BytesDecoder) tryDecodeHandle(values [][]byte, offset int, col *C
}
if col.IsPKHandle || col.ID == model.ExtraHandleID {
handleData := cacheBytes
if mysql.HasUnsignedFlag(uint(col.Flag)) {
if mysql.HasUnsignedFlag(col.Ft.Flag) {
handleData = append(handleData, UintFlag)
handleData = codec.EncodeUint(handleData, uint64(handle.IntValue()))
} else {

View File

@ -61,12 +61,8 @@ func (s *testSuite) TestEncodeLargeSmallReuseBug(c *C) {
bDecoder := rowcodec.NewDatumMapDecoder([]rowcodec.ColInfo{
{
ID: largeColID,
Tp: int32(colFt.Tp),
Flag: int32(colFt.Flag),
Ft: colFt,
IsPKHandle: false,
Flen: colFt.Flen,
Decimal: colFt.Decimal,
Elems: colFt.Elems,
},
}, []int64{-1}, nil)
m, err := bDecoder.DecodeToDatumMap(b, kv.IntHandle(-1), nil)
@ -81,12 +77,8 @@ func (s *testSuite) TestEncodeLargeSmallReuseBug(c *C) {
bDecoder = rowcodec.NewDatumMapDecoder([]rowcodec.ColInfo{
{
ID: smallColID,
Tp: int32(colFt.Tp),
Flag: int32(colFt.Flag),
Ft: colFt,
IsPKHandle: false,
Flen: colFt.Flen,
Decimal: colFt.Decimal,
Elems: colFt.Elems,
},
}, []int64{-1}, nil)
m, err = bDecoder.DecodeToDatumMap(b, kv.IntHandle(-1), nil)
@ -114,13 +106,8 @@ func (s *testSuite) TestDecodeRowWithHandle(c *C) {
fts = append(fts, t.ft)
cols = append(cols, rowcodec.ColInfo{
ID: t.id,
Tp: int32(t.ft.Tp),
Flag: int32(t.ft.Flag),
IsPKHandle: t.handle,
Flen: t.ft.Flen,
Decimal: t.ft.Decimal,
Elems: t.ft.Elems,
Collate: t.ft.Collate,
Ft: t.ft,
})
}
@ -237,22 +224,12 @@ func (s *testSuite) TestEncodeKindNullDatum(c *C) {
c.Assert(err, IsNil)
cols := []rowcodec.ColInfo{{
ID: 1,
Tp: int32(ft.Tp),
Flag: int32(ft.Flag),
Flen: ft.Flen,
Decimal: ft.Decimal,
Elems: ft.Elems,
Collate: ft.Collate,
ID: 1,
Ft: ft,
},
{
ID: 2,
Tp: int32(ft.Tp),
Flag: int32(ft.Flag),
Flen: ft.Flen,
Decimal: ft.Decimal,
Elems: ft.Elems,
Collate: ft.Collate,
ID: 2,
Ft: ft,
}}
cDecoder := rowcodec.NewChunkDecoder(cols, []int64{-1}, nil, sc.TimeZone)
chk := chunk.New(fts, 1, 1)
@ -284,13 +261,8 @@ func (s *testSuite) TestDecodeDecimalFspNotMatch(c *C) {
ft.Decimal = 3
cols := make([]rowcodec.ColInfo, 0)
cols = append(cols, rowcodec.ColInfo{
ID: 1,
Tp: int32(ft.Tp),
Flag: int32(ft.Flag),
Flen: ft.Flen,
Decimal: ft.Decimal,
Elems: ft.Elems,
Collate: ft.Collate,
ID: 1,
Ft: ft,
})
cDecoder := rowcodec.NewChunkDecoder(cols, []int64{-1}, nil, sc.TimeZone)
chk := chunk.New(fts, 1, 1)
@ -335,13 +307,8 @@ func (s *testSuite) TestTypesNewRowCodec(c *C) {
fts = append(fts, t.ft)
cols = append(cols, rowcodec.ColInfo{
ID: t.id,
Tp: int32(t.ft.Tp),
Flag: int32(t.ft.Flag),
IsPKHandle: t.handle,
Flen: t.ft.Flen,
Decimal: t.ft.Decimal,
Elems: t.ft.Elems,
Collate: t.ft.Collate,
Ft: t.ft,
})
}
@ -574,13 +541,8 @@ func (s *testSuite) TestNilAndDefault(c *C) {
fts = append(fts, t.ft)
cols = append(cols, rowcodec.ColInfo{
ID: t.id,
Tp: int32(t.ft.Tp),
Flag: int32(t.ft.Flag),
IsPKHandle: t.handle,
Flen: t.ft.Flen,
Decimal: t.ft.Decimal,
Elems: t.ft.Elems,
Collate: t.ft.Collate,
Ft: t.ft,
})
}
ddf := func(i int, chk *chunk.Chunk) error {
@ -705,13 +667,8 @@ func (s *testSuite) TestVarintCompatibility(c *C) {
fts = append(fts, t.ft)
cols = append(cols, rowcodec.ColInfo{
ID: t.id,
Tp: int32(t.ft.Tp),
Flag: int32(t.ft.Flag),
IsPKHandle: t.handle,
Flen: t.ft.Flen,
Decimal: t.ft.Decimal,
Elems: t.ft.Elems,
Collate: t.ft.Collate,
Ft: t.ft,
})
}
@ -781,13 +738,8 @@ func (s *testSuite) TestCodecUtil(c *C) {
for i, ft := range tps {
cols = append(cols, rowcodec.ColInfo{
ID: colIDs[i],
Tp: int32(ft.Tp),
Flag: int32(ft.Flag),
IsPKHandle: false,
Flen: ft.Flen,
Decimal: ft.Decimal,
Elems: ft.Elems,
Collate: ft.Collate,
Ft: ft,
})
}
d := rowcodec.NewDecoder(cols, []int64{-1}, nil)
@ -831,13 +783,8 @@ func (s *testSuite) TestOldRowCodec(c *C) {
cols := make([]rowcodec.ColInfo, len(tps))
for i, tp := range tps {
cols[i] = rowcodec.ColInfo{
ID: colIDs[i],
Tp: int32(tp.Tp),
Flag: int32(tp.Flag),
Flen: tp.Flen,
Decimal: tp.Decimal,
Elems: tp.Elems,
Collate: tp.Collate,
ID: colIDs[i],
Ft: tp,
}
}
rd := rowcodec.NewChunkDecoder(cols, []int64{-1}, nil, time.Local)
@ -862,9 +809,8 @@ func (s *testSuite) Test65535Bug(c *C) {
cols := make([]rowcodec.ColInfo, 1)
cols[0] = rowcodec.ColInfo{
ID: 1,
Tp: int32(tps[0].Tp),
Flag: int32(tps[0].Flag),
ID: 1,
Ft: tps[0],
}
dc := rowcodec.NewDatumMapDecoder(cols, []int64{-1}, nil)
result, err := dc.DecodeToDatumMap(bd, kv.IntHandle(-1), nil)