Encode encodes a row from a datums slice. `buf` is not truncated before encoding. This function may return both a valid encoded bytes and an error (actually `"pingcap/errors".ErrorGroup`). If the caller expects to handle these errors according to `SQL_MODE` or other configuration, please refer to `p
(loc *time.Location, colIDs []int64, values []types.Datum, checksum Checksum, buf []byte)
| 44 | // expects to handle these errors according to `SQL_MODE` or other configuration, please refer to `pkg/errctx`. |
| 45 | // the caller needs to ensure the key is not nil if checksum is required. |
| 46 | func (encoder *Encoder) Encode(loc *time.Location, colIDs []int64, values []types.Datum, checksum Checksum, buf []byte) ([]byte, error) { |
| 47 | encoder.reset() |
| 48 | encoder.appendColVals(colIDs, values) |
| 49 | numCols, notNullIdx := encoder.reformatCols() |
| 50 | err := encoder.encodeRowCols(loc, numCols, notNullIdx) |
| 51 | if err != nil { |
| 52 | return nil, err |
| 53 | } |
| 54 | if checksum == nil { |
| 55 | checksum = NoChecksum{} |
| 56 | } |
| 57 | return checksum.encode(encoder, buf) |
| 58 | } |
| 59 | |
| 60 | func (encoder *Encoder) reset() { |
| 61 | encoder.flags = 0 |