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

Function reEncodeHandleConsiderNewCollation

pkg/tablecodec/tablecodec.go:829–845  ·  view source on GitHub ↗

reEncodeHandleConsiderNewCollation encodes the handle as a Datum so it can be properly decoded later.

(handle kv.Handle, columns []rowcodec.ColInfo, restoreData []byte)

Source from the content-addressed store, hash-verified

827
828// reEncodeHandleConsiderNewCollation encodes the handle as a Datum so it can be properly decoded later.
829func reEncodeHandleConsiderNewCollation(handle kv.Handle, columns []rowcodec.ColInfo, restoreData []byte) ([][]byte, error) {
830 handleColLen := handle.NumCols()
831 cHandleBytes := make([][]byte, 0, handleColLen)
832 for i := 0; i < handleColLen; i++ {
833 cHandleBytes = append(cHandleBytes, handle.EncodedCol(i))
834 }
835 if len(restoreData) == 0 {
836 return cHandleBytes, nil
837 }
838 // Remove some extra columns(ID < 0), such like `model.ExtraPhysTblID`.
839 // They are not belong to common handle and no need to restore data.
840 idx := len(columns)
841 for idx > 0 && columns[idx-1].ID < 0 {
842 idx--
843 }
844 return decodeRestoredValuesV5(columns[:idx], cHandleBytes, restoreData)
845}
846
847func decodeRestoredValues(columns []rowcodec.ColInfo, restoredVal []byte) ([][]byte, error) {
848 colIDs := make(map[int64]int, len(columns))

Calls 3

decodeRestoredValuesV5Function · 0.85
NumColsMethod · 0.65
EncodedColMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…