Encode implements the KVEncoder interface.
(row []types.Datum, rowID int64)
| 82 | |
| 83 | // Encode implements the KVEncoder interface. |
| 84 | func (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 |
| 99 | func (en *TableKVEncoder) parserData2TableData(parserData []types.Datum, rowID int64) ([]types.Datum, error) { |