MCPcopy Index your code
hub / github.com/pingcap/tidb / Encode

Method Encode

pkg/executor/importer/kv_encode.go:84–96  ·  view source on GitHub ↗

Encode implements the KVEncoder interface.

(row []types.Datum, rowID int64)

Source from the content-addressed store, hash-verified

82
83// Encode implements the KVEncoder interface.
84func (en *TableKVEncoder) Encode(row []types.Datum, rowID int64) (*kv.Pairs, error) {
85 // we ignore warnings when encoding rows now, but warnings uses the same memory as parser, since the input
86 // row []types.Datum share the same underlying buf, and when doing CastValue, we're using hack.String/hack.Slice.
87 // when generating error such as mysql.ErrDataOutOfRange, the data will be part of the error, causing the buf
88 // unable to release. So we truncate the warnings here.
89 defer en.TruncateWarns()
90 record, err := en.parserData2TableData(row, rowID)
91 if err != nil {
92 return nil, err
93 }
94
95 return en.Record2KV(record, row, rowID)
96}
97
98// todo merge with code in load_data.go
99func (en *TableKVEncoder) parserData2TableData(parserData []types.Datum, rowID int64) ([]types.Datum, error) {

Callers 8

TestEncodeFunction · 0.95
TestDecodeIndexFunction · 0.95
TestEncodeRowFormatV2Function · 0.95
TestEncodeTimestampFunction · 0.95
TestDefaultAutoRandomsFunction · 0.95
TestShardRowIdFunction · 0.95

Calls 3

parserData2TableDataMethod · 0.95
TruncateWarnsMethod · 0.80
Record2KVMethod · 0.80

Tested by 8

TestEncodeFunction · 0.76
TestDecodeIndexFunction · 0.76
TestEncodeRowFormatV2Function · 0.76
TestEncodeTimestampFunction · 0.76
TestDefaultAutoRandomsFunction · 0.76
TestShardRowIdFunction · 0.76