EncodeOldRow encode row data and column ids into a slice of byte. Row layout: colID1, value1, colID2, value2, ..... valBuf and values pass by caller, for reducing EncodeOldRow allocates temporary bufs. If you pass valBuf and values as nil, EncodeOldRow will allocate it.
(loc *time.Location, row []types.Datum, colIDs []int64, valBuf []byte, values []types.Datum)
| 374 | // valBuf and values pass by caller, for reducing EncodeOldRow allocates temporary bufs. If you pass valBuf and values as nil, |
| 375 | // EncodeOldRow will allocate it. |
| 376 | func EncodeOldRow(loc *time.Location, row []types.Datum, colIDs []int64, valBuf []byte, values []types.Datum) ([]byte, error) { |
| 377 | if len(row) != len(colIDs) { |
| 378 | return nil, errors.Errorf("EncodeRow error: data and columnID count not match %d vs %d", len(row), len(colIDs)) |
| 379 | } |
| 380 | valBuf = valBuf[:0] |
| 381 | if values == nil { |
| 382 | values = make([]types.Datum, len(row)*2) |
| 383 | } |
| 384 | for i, c := range row { |
| 385 | id := colIDs[i] |
| 386 | values[2*i].SetInt64(id) |
| 387 | err := flatten(loc, c, &values[2*i+1]) |
| 388 | if err != nil { |
| 389 | return valBuf, errors.Trace(err) |
| 390 | } |
| 391 | } |
| 392 | if len(values) == 0 { |
| 393 | // We could not set nil value into kv. |
| 394 | return append(valBuf, codec.NilFlag), nil |
| 395 | } |
| 396 | return codec.EncodeValue(loc, valBuf, values...) |
| 397 | } |
| 398 | |
| 399 | func flatten(loc *time.Location, data types.Datum, ret *types.Datum) error { |
| 400 | switch data.Kind() { |
searching dependent graphs…