MCPcopy Create free account
hub / github.com/pingcap/tidb / EncodeFromOldRow

Function EncodeFromOldRow

pkg/util/rowcodec/main_test.go:40–65  ·  view source on GitHub ↗

EncodeFromOldRow encodes a row from an old-format row. this method will be used in test.

(encoder *Encoder, loc *time.Location, oldRow, buf []byte)

Source from the content-addressed store, hash-verified

38// EncodeFromOldRow encodes a row from an old-format row.
39// this method will be used in test.
40func EncodeFromOldRow(encoder *Encoder, loc *time.Location, oldRow, buf []byte) ([]byte, error) {
41 if len(oldRow) > 0 && oldRow[0] == CodecVer {
42 return oldRow, nil
43 }
44 encoder.reset()
45 for len(oldRow) > 1 {
46 var d types.Datum
47 var err error
48 oldRow, d, err = codec.DecodeOne(oldRow)
49 if err != nil {
50 return nil, err
51 }
52 colID := d.GetInt64()
53 oldRow, d, err = codec.DecodeOne(oldRow)
54 if err != nil {
55 return nil, err
56 }
57 encoder.appendColVal(colID, &d)
58 }
59 numCols, notNullIdx := encoder.reformatCols()
60 err := encoder.encodeRowCols(loc, numCols, notNullIdx)
61 if err != nil {
62 return nil, err
63 }
64 return encoder.row.toBytes(buf[:0]), nil
65}

Callers 3

TestCodecUtilFunction · 0.92
TestOldRowCodecFunction · 0.92

Calls 7

GetInt64Method · 0.95
DecodeOneFunction · 0.92
appendColValMethod · 0.80
reformatColsMethod · 0.80
encodeRowColsMethod · 0.80
toBytesMethod · 0.80
resetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…